Image on Worksheet

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
2,072
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Came across this

Re: Handling click event on images
put an image on the sheet. righlcick and click view code
you will get something like this
Private Sub Image1_Click()
End Sub


But I cannot figure out or find how to put an image on a sheet.
I did put an ActiveX image with a Picture just how I wanted but there was no Click event.
Is there some way to get a click-aware image? I want a click on it to Open a UserForm
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
If you right click on the image/shape you should be able to select "Assign Macro" and select the macro to open your UserForm.
BTW, is your main problem getting a picture/image/shape onto your sheet?
How would you like to do this? Manually or with a macro?
If with a macro. do you want the capability to choose the image?
Do you need/want the image positioned at a certain place on you sheet and does it need to be sized to fit a certain range of cells?
This will put a picture with Cell C2 as top left cell and original picture size. Change folder reference and picture name as required.
Code:
ActiveSheet.Shapes.AddPicture("C:\Folder Name\Picture Name.JPG", 0, -1, Cells(2, 3).Left, Cells(2, 3).Top, -1, -1).Name = "Picture 1"
 
Upvote 0
Thanks for the reply. I found the Active X images wasn't much good for firing a click event. So I tried just pasting one and that worked.
Then changed to your code and that was even better. I want the same picture on 5 sheets so code will be handy.
It is on cell B1 and the cell already has text in it so being able to resize is great.
Don't suppose the image can show a pop-up comment ?
 
Upvote 0
Depends on what you consider to be a pop-up comment
You can certainly make your own (UserForm) nice message that pops up when clicking the image, or if you want to a message box.
Code:
Sub Show_Message()
    MsgBox "Well, hello there, how are you?"
End Sub
 
Upvote 0
I meant one that shows as the mouse hovers over it, but looks like that's a No.
 
Upvote 0
I meant one that shows as the mouse hovers over it, but looks like that's a No.
I remember doing something a few years back:
 
Upvote 0

Have a look at the above thread. Mr Jon v/d Heyden has an answer there for you
 
Upvote 0
Struck a few gotcha's. Jolivanes unfortunately using the method disables the click event for the image.
I couldn't find a click event for ActiveX Label.
Jaafar, I have all that ready to go, but if I compile it complains about With Sheet1.CommandButton1
I don't have a command button1, or a Sheet1. I see 4 setup routines so I REMed out
all but the Image control section and renamed the worksheet "Sheet1". Then changed to With Sheet1`.Picture1.

But no joy, and that'll be because my picture isn't an image control. That had no click event I could find
so I just pasted an image onto the worksheet. With some changes would this work on a picture?
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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