共用方式為


Workbook.SheetDeactivate 事件 (2007 系統)

更新:2007 年 11 月

當停用任何工作表時發生。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel.v9.0 (在 Microsoft.Office.Tools.Excel.v9.0.dll 中)

語法

Public Event SheetDeactivate As WorkbookEvents_SheetDeactivateEventHandler

Dim instance As Workbook
Dim handler As WorkbookEvents_SheetDeactivateEventHandler

AddHandler instance.SheetDeactivate, handler
public event WorkbookEvents_SheetDeactivateEventHandler SheetDeactivate

範例

下列程式碼範例會示範 SheetDeactivate 事件的處理常式。這個事件處理常式會顯示停用的工作表名稱。

這是示範文件層級自訂的範例。

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");
}

使用權限

請參閱

參考

Workbook 類別

Workbook 成員

Microsoft.Office.Tools.Excel 命名空間