Share via


Workbook.ActivateEvent Event (2007 System)

Occurs when the workbook is activated.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Event ActivateEvent As WorkbookEvents_ActivateEventHandler
'Usage
Dim instance As Workbook 
Dim handler As WorkbookEvents_ActivateEventHandler 

AddHandler instance.ActivateEvent, handler
public event WorkbookEvents_ActivateEventHandler ActivateEvent
public:
 event WorkbookEvents_ActivateEventHandler^ ActivateEvent {
    void add (WorkbookEvents_ActivateEventHandler^ value);
    void remove (WorkbookEvents_ActivateEventHandler^ value);
}
JScript does not support events.

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.

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 Sub ThisWorkbook_ActivateEvent() Handles Me.ActivateEvent
    Globals.Sheet1.Activate()
End Sub
private void WorkbookActivateEvent()
{
    this.ActivateEvent +=
        new Excel.WorkbookEvents_ActivateEventHandler(
        ThisWorkbook_ActivateEvent);
}

private void ThisWorkbook_ActivateEvent()
{
    Globals.Sheet1.Activate();
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace