WindowActivate Event

Microsoft Word Visual Basic

WindowActivate Event

       

Occurs when any document window is activated.

Private Sub object_WindowActivate(ByVal Doc As Word.Document, ByVal Wn As Word.Window)

object   An object of type Application declared with events in a class module. For more information about using events with the Application object or the Document object, see Using Events with the Application Object or Using Events with the Document Object.

Doc   Used only with the Application object. The document displayed in the activated window.

Wn   The window that's being activated.

Example

This example maximizes any document window when it's activated. This code must be placed in a class module, and an instance of the class must be correctly initialized in order to see this example work; see Using Events with the Application Object for directions on how to accomplish this.

Public WithEvents appWord as Word.Application

Private Sub appWord_WindowActivate _
        (ByVal Wn As Word.Window)
    Wn.WindowState = wdWindowStateMaximize
End Sub