Consulting

Results 1 to 5 of 5

Thread: Sheet Buttons Flashing When Mouse Over Userform

  1. #1
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location

    Sheet Buttons Flashing When Mouse Over Userform

    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

    Demo5.xlsm

  2. #2
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    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?

    Demo5.xlsm

  3. #3
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    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

  4. #4
    VBAX Mentor
    Joined
    Jan 2006
    Posts
    323
    Location
    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

  5. #5
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Gary,

    Glad that helped.

    Mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •