ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What's wrong with this code? (https://www.excelbanter.com/excel-programming/403980-whats-wrong-code.html)

xavi garriga

What's wrong with this code?
 
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!!

--
atrep

carlo

What's wrong with this code?
 
You don't need to select it:

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

cheers
Carlo

On Jan 10, 5:34*pm, xavi garriga
wrote:
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!!

--
atrep



Bob Phillips

What's wrong with this code?
 
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)



"xavi garriga" wrote in message
...
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!!

--
atrep




xavi garriga

What's wrong with this code?
 
Thank you!
--
atrep


"Bob Phillips" wrote:

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)



"xavi garriga" wrote in message
...
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!!

--
atrep






All times are GMT +1. The time now is 02:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com