Activate, Deactivate Events

Microsoft Visual Basic Constants

Activate, Deactivate Events

           

The Activate event occurs when an object becomes the active window. The Deactivate event occurs when an object is no longer the active window.

Syntax

Private Sub object_Activate()

Private Sub object_Deactivate()

The object placeholder represents an object expression that evaluates to an object in the Applies To list.

Remarks

An object can become active by using the Show method in code.

The Activate event can occur only when an object is visible. A UserForm loaded with Load isn't visible unless you use the Show method.

The Activate and Deactivate events occur only when you move the focus within an application. Moving the focus to or from an object in another application doesn't trigger either event.

The Deactivate event doesn't occur when unloading an object.