And while I'm asking questions about user forms with ShowModal set to False,
how do I detect when the user has activated another window (the user form has
lost focus) and when the user returns to the user form?

Bear

Re: Nonmodal user form focus by Jezebel

Jezebel
Wed Nov 16 19:28:22 CST 2005

Write code for the form's Activate and Deactivate events.


"Bear" <Bear@discussions.microsoft.com> wrote in message
news:6443FB75-B119-4018-BD70-4EC89914AC94@microsoft.com...
> And while I'm asking questions about user forms with ShowModal set to
> False,
> how do I detect when the user has activated another window (the user form
> has
> lost focus) and when the user returns to the user form?
>
> Bear



Re: Nonmodal user form focus by Bear

Bear
Thu Nov 17 08:41:04 CST 2005

Jezebel:

(Word 2000, Windows XP)

Maybe I'm testing this wrongly, but putting a simple MsgBox in the Activate
and Deactivate events does nothing. Well, the activate message box is
displayed when the form is initially shown. But switching between the
document and the user form (by clicking in one or the other) has no effect.

What am I doing wrong?

Bear


RE: Nonmodal user form focus by Bear

Bear
Tue Dec 13 11:20:04 CST 2005

Just to bring this thread up to date with what I've discovered.

There is no way to detect when a modeless userform gains or loses focus. I
found out how to determine the caption of the active window, using the
Windows API. But that's a far cry from a working activate and deactivate
event that treats the userform as a separtate window.

Bear