VBA Image change On Mouse Over

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
Hi there,

I have a userform that contains an image. I want to be able to alternate between that image and a a darker/lighter version of that image when the user moves the cursor over it (resetting it to the original image when the user moves the cursor off the image).

Is this possible?

Andy
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
That's great thank you, I was about ready to pull my hair out! Incase anyone is interested, this is what I came up with...

Code:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
       
'   =============================================================================================
'   This macro will reset all images to the original default state.
'   =============================================================================================
       
    Dim Server As String
    
    Server = Worksheets("Calculation Matrix").Range("CalculationMatrix_Server").Value

    imgExampleButton2.Picture() = LoadPicture("" & Server & "Database\Graphics\Button Toolbox (Light).gif")
    
End Sub

Sub imgExampleButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

'   =============================================================================================
'   This macro will change the image to a darker version when the cursor passes over it.
'   =============================================================================================

    Dim Server As String
    
    Server = Worksheets("Calculation Matrix").Range("CalculationMatrix_Server").Value

    imgExampleButton2.Picture() = LoadPicture("" & Server & "Database\Graphics\Button Toolbox (Dark).gif")

End Sub

Hope this helps.

Andy
 
Upvote 0

Forum statistics

Threads
1,213,535
Messages
6,114,194
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