Compartir a través de


WorkbookBase.ActivateEvent Event

Definition

Occurs when the workbook is activated.

public:
 event Microsoft::Office::Interop::Excel::WorkbookEvents_ActivateEventHandler ^ ActivateEvent;
public event Microsoft.Office.Interop.Excel.WorkbookEvents_ActivateEventHandler ActivateEvent;
member this.ActivateEvent : Microsoft.Office.Interop.Excel.WorkbookEvents_ActivateEventHandler 
Public Custom Event ActivateEvent As WorkbookEvents_ActivateEventHandler 

Event Type

Examples

The following code example demonstrates a handler for the ActivateEvent event. The event handler displays worksheet Sheet1 when the workbook is activated.

This example is for a document-level customization.

private void WorkbookActivateEvent()
{
    this.ActivateEvent +=
        new Excel.WorkbookEvents_ActivateEventHandler(
        ThisWorkbook_ActivateEvent);
}

private void ThisWorkbook_ActivateEvent()
{
    Globals.Sheet1.Activate();
}
Private Sub ThisWorkbook_ActivateEvent() Handles Me.ActivateEvent
    Globals.Sheet1.Activate()
End Sub

Remarks

When you switch between two windows showing the same workbook, the WindowActivate event occurs, but the ActivateEvent event for the workbook does not occur.

This event does not occur when you create a new window.

Applies to