Partilhar via


WorkbookBase.Shutdown Event

Occurs when the workbook host item shuts down.

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 Shutdown As EventHandler
public event EventHandler Shutdown

Remarks

This is the last event to be called in the WorkbookBase class as the WorkbookBase class unloads. Use this event for any additional clean up.

In a document-level customization, the application domain for the assembly unloads when the workbook host item shuts down.

In an application-level add-in, the application domain does not unload when the workbook host item shuts down. Also, the underlying workbook object is no more available. To access the workbook before it shuts down use BeforeClose instead.

Examples

The following code example demonstrates a handler for the Shutdown event. The event handler displays a message when the WorkbookBase class unloads.

This example is for a document-level customization.

Private Sub ThisWorkbook1_Shutdown(ByVal sender As Object, _
    ByVal e As EventArgs) Handles Me.Shutdown
    MsgBox("The workbook is shutting down")
End Sub
private void WorkbookShutdown()
{
    this.Shutdown += new EventHandler(ThisWorkbook1_Shutdown);
}

void ThisWorkbook1_Shutdown(object sender, EventArgs e)
{
    MessageBox.Show("The workbook is shutting down");
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace