View Full Version : [SOLVED:] Sheet Buttons Flashing When Mouse Over Userform
zoom38
04-22-2016, 05:10 PM
Hello, my file has a userform that becomes visible on file open. When moving the mouse onto the userform (blue area, see attached) the sheet buttons flash and the mouse pointer starts going in a circle as if code is in progress. When you move the mouse over a button on the user form it stops. I can't seem to figure out which event is causing this. Can some one take a look at the attached file and point me in the right direction.
Thanks
Gary
15985
zoom38
04-24-2016, 06:24 PM
So I commented the Application.ScreenUpdating = False line in the userform mousemove event and the buttons on the sheet stopped flashing. But now the buttons on the userform flash as the mouse is moved. Is there a way to stop the buttons from flashing when the mouse is moved on the userform?
16008
Try:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
Dim contr As Control
For Each contr In UserForm1.Controls
If TypeName(contr) = "CommandButton" And Not contr.BackColor = &HE0E0E0 Then
contr.BackColor = &HE0E0E0
contr.ForeColor = &H800000
DoEvents
End If
Next
End Sub
I am not sure why it seems to be picking up mouse moves even when the mouse is not moving, but the event seems to keep firing. Also, CTRL + Pause doesn't seem to catch, and as none of the buttons kill the form, you have to use ALT + Spacebar & C to dismiss the form.
Mark
zoom38
04-25-2016, 05:10 AM
Mark you are awesome. I spent a multitude of hours over 3 days trying different things and scouring all over the internet for a solution and came up empty. Your simple code change solved it. Bye the way the flashing was much more pronounced in Excel 2007 than was in Excel 2013.
Also I purposely removed the userform caption and x to exit because the userform is being used for all sheets. I don't want the user to be able to dismiss or close the form.
Thanks for taking the time to help.
Gary
Hi Gary,
Glad that helped.
Mark
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.