Document.Shutdown Event (2007 System)

Occurs when the document host item shuts down.

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

Syntax

'Declaration
Public Event Shutdown As EventHandler
'Usage
Dim instance As Document 
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 Document class as the Document class unloads. Use this event for any additional clean up.

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

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

Examples

The following code example adds a new Shutdown event handler that displays a message that shows that the document is shutting down.

This example is for a document-level customization.

Private Sub DocumentShutdown()
    AddHandler Me.Shutdown, AddressOf ThisDocument_Shutdown2
End Sub 

Private Sub ThisDocument_Shutdown2(ByVal sender As Object, ByVal e As System.EventArgs)
    MessageBox.Show("The Shutdown event was raised.")
End Sub
private void DocumentShutdown()
{
    this.Shutdown +=new EventHandler(ThisDocument_Shutdown2);

}

private void ThisDocument_Shutdown2(object sender, System.EventArgs e)
{
    MessageBox.Show("The Shutdown event was raised.");
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace

Change History

Date

History

Reason

July 2008

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

SP1 feature change.