PDA

View Full Version : Showing and Hiding a picture



pingwin77
03-12-2009, 10:48 AM
I have the following sheet in a workbook. I need a VBA code to link to a Form Button. I need 1 button to make the A2LA picture in the upper right corner disappear. I also need 1 button to make the A2LA picture reappear. The buttons will be on a a different sheet. (sheet 1)

Thanks for the help.

lucas
03-12-2009, 12:26 PM
Well, I see the A2LA buttons but which picture are you talking about.

You would have to have a copy of the picture somewhere, maybe another sheet and delete it and copy and paste it using your buttons.

pingwin77
03-12-2009, 01:12 PM
The picture is on the next sheet in the workbook. "Comments" I need it to stay in that location on that sheet and just disappear and reappear.

lucas
03-12-2009, 01:23 PM
Yes but which picture. I don't think you can just make it disappear, as I said before, you will probably have to delete it and then copy it from somewhere else and paste it to put it back.

BrianMH
03-12-2009, 01:33 PM
how about resizing it so it would be practically invisible?

pingwin77
03-12-2009, 01:35 PM
Is there a way to change the properties to move it to the back or front using a code like this? I don't know how to change the ("A2LA_Logo") part of this. I am replacing a picture and this code just moves it.

Application.ScreenUpdating = False
Sheets("Cert").Shapes("A2LA_Logo").ZOrder msoBringToFront
Sheets("Uncert").Shapes("A2LA_Logo").ZOrder msoBringToFront
Sheets("Comments").Shapes("A2LA_Logo").ZOrder msoBringToFront
Sheets("Controls").Shapes("A2LA_Logo").ZOrder msoSendToBack
Range("G5").Select

jolivanes
03-12-2009, 01:40 PM
Can't find a picture anywhere but is this what you're after?

John

pingwin77
03-12-2009, 01:44 PM
OK, I guess the question I have is how to find the label for the picture? In the cod I provided, the label was "A2LA_Logo". In the code you provided it is "picture 1". how do I figure out the label to work with a different picture?

jolivanes
03-12-2009, 01:58 PM
You can change the generic name of the object in the name box left above your column headers.
See attached

John

mdmackillop
03-12-2009, 01:59 PM
Draw a white rectangle over the picture, use the following to move it to the back or front
ActiveSheet.Shapes("Rectangle 1").ZOrder 1 'Hide

ActiveSheet.Shapes("Rectangle 1").ZOrder 0 'Show

mdmackillop
03-12-2009, 02:01 PM
Can't find a picture anywhere but is this what you're after?

John

I missed your better solution, but maybe
Sub SeeOrNotSee()
With Sheets("Sheet1").Shapes("Picture 1")
.Visible = Not .Visible
End With
End Sub

jolivanes
03-12-2009, 02:18 PM
mdmackillop.
Your knowledge (of excel) is superior to mine. I am learning from all you guys here on the forums and I do appreciate that very much. As a matter of fact, sometimes I have a hard time understanding some people with their very impolite questions/answers as you and lucas recently experienced. My hat off to all of you.

Regards.
John

mdmackillop
03-12-2009, 02:30 PM
Hi John,
Can't think why I missed the Visible solution, I was distracted by some of the other suggestions I guess.

I think we can all learn from each other. There are different solutions to problems, and trimming down code to the essentials comes with practice (and seeing how others do it)

pingwin77
03-12-2009, 02:43 PM
I'll have to add that to my work book but it looks like it should work. Thanks for all the help everyone. I look forward to the days where i know more and can support others the way you all have for me. Thanks again!

BrianMH
03-12-2009, 02:45 PM
I love this forum. Learning more every day. I never knew about the NOT operator. I really do love programming and every day I learn how to cut down code to something simpler.

jolivanes
03-12-2009, 03:12 PM
mdmackillop.



I think we can all learn from each other. There are different solutions to problems.


Isn't that true. Even at my age, close to retirement, one never stops learning or picking up better ways of solving problems.

Regards.
John