What's wrong with this code?

  • Thread starter Thread starter xavi garriga
  • Start date Start date
X

xavi garriga

Hi to all!

I've inserted one image via Insert/image/from file.
I've created as well a button, this commandbutton has this code:

ActiveSheet.Shapes("Picture 1").Select
Selection.ShapeRange.Visible = False

and the image (of course) disappear.

With another commandbutton, I want this image to appear again, I've written
this code:

ActiveSheet.Shapes("Picture 1").Select
Selection.ShapeRange.Visible = True

This last code doesn't work, because there is not "picture 1" to select. How
can I make this image to appear again?

Thanks to all!!
 
You don't need to select it:

ActiveSheet.Shapes("Picture 1").Visible = False
ActiveSheet.Shapes("Picture 1").Visible = True

cheers
Carlo
 
There is no need to select, and no need for ShapeRange

ActiveSheet.Shapes("Picture 1").Visible = False

and

ActiveSheet.Shapes("Picture 1").Visible = True


But you can do it all with one commandbutton

With ActiveSheet.Shapes("Picture 1")
.Visible = Not .Visible
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Thank you!
--
atrep


Bob Phillips said:
There is no need to select, and no need for ShapeRange

ActiveSheet.Shapes("Picture 1").Visible = False

and

ActiveSheet.Shapes("Picture 1").Visible = True


But you can do it all with one commandbutton

With ActiveSheet.Shapes("Picture 1")
.Visible = Not .Visible
End With

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top