WindowActivate Event

Microsoft Excel Visual Basic

Occurs when any workbook window is activated.

Private Sub object_WindowActivate(ByVal Wb As Excel.Workbook, ByVal Wn As Excel.Window)

object    Application or Workbook. For more information about using events with the Application object, see Using Events with the Application Object.

Wb    Used only with the Application object. The workbook displayed in the activated window.

Wn    The activated window.

Example

This example maximizes any workbook window when it's activated.

Private Sub Workbook_WindowActivate(ByVal Wn As Excel.Window)
    Wn.WindowState = xlMaximized
End Sub