Workbook.Shutdown Event (2007 System)
Occurs when the workbook host item shuts down.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
'Declaration
Public Event Shutdown As EventHandler
'Usage
Dim instance As Workbook
Dim handler As EventHandler
AddHandler instance.Shutdown, handler
public event EventHandler Shutdown
public:
event EventHandler^ Shutdown {
void add (EventHandler^ value);
void remove (EventHandler^ value);
}
JScript does not support events.
This is the last event to be called in the Workbook class as the Workbook 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.
The following code example demonstrates a handler for the Shutdown event. The event handler displays a message when the Workbook 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");
}
- 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.
Microsoft.Office.Tools.Excel Namespace
Date |
History |
Reason |
---|---|---|
July 2008 |
Added additional remarks that are specific to application-level add-ins. |
SP1 feature change. |