This is the mouse over code to change a form button red from green. You need a form and a button to test the code. JSW
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'On mouse-over, color form back Lt.Blue.
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
'On mouse-over, color Button Green.
If CommandButton1.BackColor<> RGB(122, 255, 0) Then _
CommandButton1.BackColor = RGB(122, 255, 100)
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
'On mouse-over = gone, color form back Lt.Blue.
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
'On mouse-over = gone, color Button Red.
If CommandButton1.BackColor<> RGB(255, 0, 0) Then _
CommandButton1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub UserForm_Activate()
'On form open color Back Lt.Blue.
UserForm1.BackColor = RGB(220, 247, 247)
'On form open color Button Bright Red.
If CommandButton1.BackColor<> RGB(255, 0, 0) Then _
CommandButton1.BackColor = RGB(255, 0, 0)
End Sub
Private Sub CommandButton1_Click()
'Deactivate UserForm & color back Lt.Gray.
UserForm1.BackColor = RGB(240, 240, 240)
'Show Msg.
MsgBox Chr(13) & Chr(13) & _
"This could have been any Visual Basic code or Macro!" _
& Chr(13) & Chr(13) & _
"The UserForm ""Button"" has activated this code." _
& Chr(13) & Chr(13) & _
"Any code can be placed here!" _
& Chr(13) & Chr(13) & Chr(13) & Chr(13) & _
" Press ""OK"" when done!" _
& Chr(13)
' This is the click event for UserForm1
'Private Sub UserForm_Click()
'Note: the button will print the userform!
'You may want to comment out the print below!
UserForm1.PrintForm
'End Sub
If UserForm1.BackColor = RGB(240, 240, 240) Then _
UserForm1.BackColor = RGB(220, 247, 247)
End Sub
Private Sub UserForm_Click()
'If UserForm Background is clicked, close form.
UserForm1.Hide
End Sub
This message was edited by Joe Was on 2002-11-20 20:38