Log in

View Full Version : Alert when modeless userform loses focus



Jfp87
09-02-2016, 07:36 AM
Guys,

I am using a modeless UserForm while using the document itself to edit some text. The idea is that the UserForm will sit at the side of the document while editing. The UserForm has a checkbox which gives the option to alert the user if not in editing mode; this would mean showing a msgbox (or something similar) when the user clicks somewhere in the document and the UserForm loses focus. As far as I know, there are no UserForm events which cover this.

My initial thought was to insert a large Content Control and use its OnEnter event, but I don't want to go down that route.

What else can I try?

Joe

SamT
09-02-2016, 11:43 AM
I can't see why you would nee that feature. Surely the User knows where the mouse is and where he/she just clicked.

This might work, but it's behavior is a bit hinky.

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If X = 0 Then MsgBox "you have left the form"
End Sub

There is also Windows API, and it's calls and events that would work.

Jfp87
09-03-2016, 03:19 AM
Thanks for the reply SamT...I will try that.