Udostępnij za pośrednictwem


Workbook.SheetDeactivate Event (2007 System)

Occurs when any sheet is deactivated.

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

Syntax

'Declaration
Public Event SheetDeactivate As WorkbookEvents_SheetDeactivateEventHandler
'Usage
Dim instance As Workbook 
Dim handler As WorkbookEvents_SheetDeactivateEventHandler 

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

Examples

The following code example demonstrates a handler for the SheetDeactivate event. The event handler displays the name of the worksheet that was deactivated.

This example is for a document-level customization.

Private Sub ThisWorkbook_SheetDeactivate(ByVal Sh As Object) _
    Handles Me.SheetDeactivate

    Dim sheet As Excel.Worksheet = CType(Sh, Excel.Worksheet)
    MsgBox(sheet.Name & " Deactivated")
End Sub
private void WorkbookSheetDeactivate()
{
    this.SheetDeactivate +=
        new Excel.WorkbookEvents_SheetDeactivateEventHandler(
        ThisWorkbook_SheetDeactivate);
}

private void ThisWorkbook_SheetDeactivate(object Sh)
{
    Excel.Worksheet sheet = (Excel.Worksheet)Sh;
    MessageBox.Show(sheet.Name + " Deactivated");
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace