Show picture when 'hover' a shape in worksheet

ybr_15

Board Regular
Joined
May 24, 2016
Messages
204
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
I have 3 shape and 3 picture in my worksheet. I write in the 1st shape "Andy", 2nd shape "Diana", and 3rd shape "Luis" for example. Now, I want to show his/her picture (Example: Andy's picture for shape "Andy", and so on) when I hover at the shape. Can you help me (code/function) how to do that?. Thank you very much
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,

There is no "MouseOver" Event for a Shape which means that we can't do this directly.

However, ActiveX Controls do have a MouseOver Event so we could use as described here: https://www.youtube.com/watch?v=iyXj4YyCKxY

Basically, you layer two ActiveX Labels and your original Shape. You need another shape for the pop-up Picture, as well. Mine was called "myPicture". You need to know the name for the code below.

First, you make one Label smaller than the Shape and a second one larger. Then you make a sandwich with the small Label on the top, the large Label next and the Shape on the bottom. You also need the Shape to hold the Picture. Then you Group all these things together. The Labels were called label1 and Label2 to match the code below.

Now you need a couple of Event Handlers to process the MouseOver Events, like this:
Code:
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.Shapes("myPicture").Visible = False
End Sub

Private Sub Label2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.Shapes("myPicture").Visible = True
End Sub
The above code was inserted into the module for the Worksheet with the Shapes on it.

It is probably easier to see how it all works from the video in the link.

How reliable the functionality is depends on how you arrange the overlap of the labels.

Regards,
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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