WindowDeactivate Event

Microsoft Word Visual Basic

WindowDeactivate Event

       

Occurs when any document window is deactivated.

Private Sub object_WindowDeactivate(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 deactivated window.

Wn   The deactivated window.

Example

This example minimizes any document window when it's deactivated. 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_WindowDeactivate _
        (ByVal Wn As Word.Window)
    Wn.WindowState = wdWindowStateMinimize
End Sub