Show Picture on Mouse Hover with VBA

In Excel you can hover the mouse over a cell to display a picture.  The following is a bit of a novelty but as the saying goes a picture tells a thousand words.  What the procedure does is it will display a picture as you mouse over a Macro Command button.  It might come in handy for showing a description of what will happen if the button is clicked on, perhaps a picture of a mushroom cloud would be appropriate!!!

The picture will show without the button being clicked on.

Mouse Over Excel VBA

The following is the code for the Mouse over event.

Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim sh As Worksheet
Set sh=Sheet1
If sh.Pictures("Smallman").Visible=False Then 'Smallman is the name of the pic
sh.Pictures("Smallman").Visible=True
End If
sh.Shapes("Label1").Visible=True 'This line is the most important (No Delete)
End Sub

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim sh As Worksheet
Set sh=Sheet1

If sh.Pictures("Smallman").Visible=True Then 'Smallman is the name of the pic
sh.Pictures("Smallman").Visible=False
End If
sh.Shapes("Label1").Visible=False 'This line is the most important (No Delete)
End Sub

If you want the Command Button to perform an Action as well then the following will help.

Private Sub CommandButton1_Click() 'Excel VBA for command button add.
MsgBox "Your Macro Here"
End Sub

The theory is to have two mouse over events, one to kick the procedure off and another to turn it off.  Rolling the mouse over the button will turn the picture on (visible).  There is a very small label surrounding the label which is hidden. This provides the Mouse off procedure to remove the picture.