Dela via


Worksheet.Shutdown Event (2007 System)

Occurs when the worksheet host item shuts down.

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

Syntax

'Declaration
Public Event Shutdown As EventHandler
'Usage
Dim instance As Worksheet 
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.

Remarks

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

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

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

Examples

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

This example is for a document-level customization.

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

void Worksheet1_Shutdown(object sender, EventArgs e)
{
    MessageBox.Show(this.Name + " is shutting down.");
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace

Change History

Date

History

Reason

July 2008

Added additional remarks that are specific to an application-level add-in.

SP1 feature change.