Create a VBA button to open an image in worksheet

gary2014

Board Regular
Joined
Mar 31, 2012
Messages
67
Hi!

(Sub-Create a button to open an image in worksheet)

I've been asked to have an image (small jpg file) appear and disappear in an Excel worksheet that is being used as a form. In other words, they want the user to click on a Command Button which will display an image, then give him/her the option to click the button again and the image disappears (They didn't specifically ask for a button, but I guess a button is the best option based on what I read on other threads in this forum, however if there is an alternative, that would work for me too!).

I have no experience with VBA, and I wasn't able to find a similar example to my situation in this forum, where I could copy and paste the code in VB.
ABCD
1
Command Button 1 (Click here Mobile Phone pic)
The Mobile Phone pic should display here
2Command Button 2 (Click here Head Phone pic)The Head Phone pic should display here
3Command Button 3 (Click here Land Phone pic)The Land Phone pic should display here
4

<tbody>
</tbody>
The Mobile phone pic is already in this same worksheet (Cell B90)
The Head phone pic is already in this same worksheet (Cell B113)
The Land phone pic is already in this same worksheet (Cell B135)

Please revert back if I am not clear
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
place your pic in B1, then rename it as "MobilePhone"

go to developer tab, add a toggle button, double click it and put this code in it

Code:
Private Sub ToggleButton1_Click()
    Me.Pictures("MobilePhone").Visible = ToggleButton1.Value
End Sub
 
Upvote 0
A small confusion!!

By pic i mean to say, its a screenshot (copy/ pasted from MS Paint) in sheet 1 & cell B90.
I'm not sure if we can rename a screenshot....!!

Can't there be any other alternatve, where we can directly link the screenshot to the desired command 1 button?

My concept: I want to select the screenshots which i already saved in sheet 1.. whereas sheet 2 has other screenshots and likewise i have 40 sheets in a workbook & All these 40 sheets will have 3 command buttons with 1 unique screenshot assigned.
 
Upvote 0
have you tried what i suggested?
i think it should do what you want and its easy to implement
 
Upvote 0
But why send me a private message with this exact post in and not allow replies when I try and tell you that there's an answer on the forum?

Confused :eek:
 
Upvote 0
I'm very sorry Darren.
I just noticed that my settings disabled the incoming msgs.

I have activated it now.

Looking forward for your help.
 
Upvote 0
Hi VBA Geek,
I tried but it failed or I did it incorrect.

Reasons:
1. I'm copy/pasting the screenshot in B1, but not sure how can I rename it....because is not saved in any file.

Could you please be more specific?

Thanks in advance.
 
Upvote 0
one your pictures is in excel, if you select it, above on the left you will be able to assign it a name



Hi VBA Geek,
I tried but it failed or I did it incorrect.

Reasons:
1. I'm copy/pasting the screenshot in B1, but not sure how can I rename it....because is not saved in any file.

Could you please be more specific?

Thanks in advance.
 
Upvote 0
Hi <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); font-style: italic; background-color: rgb(242, 246, 248);">VBA</acronym> Geek,

I tried with the following steps:

1. Opened an excl sheet.
2. In Sheet 1 > B2 > I pasted my Screenshot.
3. Neither the cell B2 or
Screenshot display any option to rename it.
4. I tried all options!!!...

Plzzz help
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,465
Members
448,965
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top