Consulting

Results 1 to 3 of 3

Thread: Alert when modeless userform loses focus

  1. #1
    VBAX Regular
    Joined
    Jul 2014
    Posts
    79
    Location

    Alert when modeless userform loses focus

    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

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Regular
    Joined
    Jul 2014
    Posts
    79
    Location
    Thanks for the reply SamT...I will try that.

Posting Permissions

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