WorkbookBase.WindowActivate Event

Definition

Occurs when any workbook window is activated.

public event Microsoft.Office.Interop.Excel.WorkbookEvents_WindowActivateEventHandler WindowActivate;

Event Type

WorkbookEvents_WindowActivateEventHandler

Examples

The following code example demonstrates a handler for the WindowActivate event. The event handler maximizes the workbook window that was activated.

This example is for a document-level customization.

private void WorkbookWindowActivate()
{
    this.WindowActivate +=
        new Excel.WorkbookEvents_WindowActivateEventHandler(
        ThisWorkbook_WindowActivate);
}

private void ThisWorkbook_WindowActivate(Excel.Window Wn)
{
    Wn.WindowState = Excel.XlWindowState.xlMaximized;
}
Private Sub ThisWorkbook_WindowActivate(ByVal Wn As Excel.Window) _
    Handles Me.WindowActivate
    Wn.WindowState = Excel.XlWindowState.xlMaximized
End Sub

Applies to