Udostępnij za pośrednictwem


WorkbookBase.ActivateEvent Event

Occurs when the workbook is activated.

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

Syntax

'Declaration
Public Event ActivateEvent As WorkbookEvents_ActivateEventHandler
public event WorkbookEvents_ActivateEventHandler ActivateEvent

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

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace