Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlight Button... 2

Status
Not open for further replies.

NumberCrunchingMonky

Technical User
Feb 5, 2004
30
US
I created a database in Excel and attached buttons to control macros. No problem. I'd like to add code that will change the appearance of the buttons from raised to sunken when the cursor/pointer moves over them, like in html app's.

What code can I add to do this, and where should it go (standard module, etc...).

Thanks.

Monky
 
The macro buttons have a FaceID, and you can change that by code. However, I am not sure how you would get a MouseOver like event to fire. The buttons themselves do not have a MouseOver event. You could do it by code detecting the mouse location, but frankly it seems a waste of resources. It would take more code than it is worth.

Gerry
 
Monky
The following will achieve something like you are after (well, it changes the colour!) but only on a UserForm not on a worksheet. These utilise the MouseMove event of both the commandbutton and the form itself.

All code resides in the form's module

Code:
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    Me.CommandButton1.BackColor = &HC0C0FF
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Me.CommandButton1
    If X < .Left Or X > .Left + .Width Or Y < .Top Or Y > .Top + .Height Then
        .BackColor = &H8000000F
    End If
End With
End Sub

;-)


If a man says something and there are no women there to hear him, is he still wrong? [ponder]
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top