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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

AndrewKent

Well-known Member
Joined
Jul 26, 2006
Messages
889
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,194
Messages
5,768,778
Members
425,494
Latest member
Ragamacam

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
Top