Workbook.SheetActivate Event (2007 System)
Occurs when any sheet 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 SheetActivate As WorkbookEvents_SheetActivateEventHandler
'Usage
Dim instance As Workbook
Dim handler As WorkbookEvents_SheetActivateEventHandler
AddHandler instance.SheetActivate, handler
public event WorkbookEvents_SheetActivateEventHandler SheetActivate
public:
event WorkbookEvents_SheetActivateEventHandler^ SheetActivate {
void add (WorkbookEvents_SheetActivateEventHandler^ value);
void remove (WorkbookEvents_SheetActivateEventHandler^ value);
}
JScript does not support events.
Examples
The following code example demonstrates a handler for the SheetActivate event. The event handler displays the name of the worksheet that is activated.
This example is for a document-level customization.
Private Sub ThisWorkbook_SheetActivate(ByVal Sh As Object) _
Handles Me.SheetActivate
Dim sheet As Excel.Worksheet = CType(Sh, Excel.Worksheet)
MsgBox(sheet.Name & " Activated")
End Sub
private void WorkbookSheetActivate()
{
this.SheetActivate +=
new Excel.WorkbookEvents_SheetActivateEventHandler(
ThisWorkbook_SheetActivate);
}
private void ThisWorkbook_SheetActivate(object Sh)
{
Excel.Worksheet sheet = (Excel.Worksheet)Sh;
MessageBox.Show(sheet.Name + " Activated");
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.