ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Image controled by VB tools (https://www.excelbanter.com/excel-discussion-misc-queries/235309-image-controled-vbulletin-tools.html)

jorlypong

Image controled by VB tools
 
How do I turn on and off the visibility of an image using a radio button or
check box? My problem is in having VB locate the image. How do I name the
image so I may then refernce it in VB?

Shane Devenshire[_2_]

Image controled by VB tools
 
Hi,

With an image in the spreadsheet and the cursor in a cell, turn on the Macro
Recorder and select the image, then turn off the recorder and view your code.
This will tell you what the object name currently is, then add the following
code to the Sheet1 object (or whatever sheet your object is on). This is
done in the VBE by double-clicking the sheet name in the top left corner of
the screen.

Private Sub CheckBox1_Click()
If Me.CheckBox1 = True Then
ActiveSheet.Shapes("Picture 12").Visible = True
Else
ActiveSheet.Shapes("Picture 12").Visible = False
End If
End Sub


--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"jorlypong" wrote:

How do I turn on and off the visibility of an image using a radio button or
check box? My problem is in having VB locate the image. How do I name the
image so I may then refernce it in VB?


jorlypong

Image controled by VB tools
 
That was my first thought but the macro never recognized my picture or shape
(code in VB was blank for those actions). When looking at the properties of
the worksheet it only shows the worksheet itself and my checkbox; therefore,
I can't command it because I don't know the pictures name. Any other ideas?



"Shane Devenshire" wrote:

Hi,

With an image in the spreadsheet and the cursor in a cell, turn on the Macro
Recorder and select the image, then turn off the recorder and view your code.
This will tell you what the object name currently is, then add the following
code to the Sheet1 object (or whatever sheet your object is on). This is
done in the VBE by double-clicking the sheet name in the top left corner of
the screen.

Private Sub CheckBox1_Click()
If Me.CheckBox1 = True Then
ActiveSheet.Shapes("Picture 12").Visible = True
Else
ActiveSheet.Shapes("Picture 12").Visible = False
End If
End Sub


--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"jorlypong" wrote:

How do I turn on and off the visibility of an image using a radio button or
check box? My problem is in having VB locate the image. How do I name the
image so I may then refernce it in VB?



All times are GMT +1. The time now is 05:13 PM.

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