(Solved) – How to force Excel Userform to be Active /Receiving Window

  • by
(solved)-–-how-to-force-excel-userform-to-be-active-/receiving-window

A Mousemove event within a RichTextBox is fired and so it appears to the user that is where the focus is. However, the underlying spreadsheet can still have the focus with any keystroke being received there. I have been unable to find any code to use with the Mousemove event to bring the focus back to the Userform and the RichTextBox.

Private Sub RBXDups_MouseMove(ByVal Button As Integer, _
   ByVal Shift As Integer, ByVal X As stdole.OLE_XPOS_PIXELS, _
   ByVal Y As stdole.OLE_YPOS_PIXELS)
     Me.Textbox1.value = X & " =X  Y=" & Y
     Me.RichTextBox1.SetFocus
end sub

The textbox displays the XY cordinates, but the focus remains with and the sheet receives the keystrokes. Right clicking within the Richtextbox moves the focus and keystrokes are processed by the userform.
How to get the focus back to the Userform and Richtextbox with a VBA command?

Leave a Reply

Your email address will not be published. Required fields are marked *