DocumentBase.CloseEvent Event

Definition

Occurs when the document is closed.

public event Microsoft.Office.Interop.Word.DocumentEvents2_CloseEventHandler CloseEvent;

Event Type

DocumentEvents2_CloseEventHandler

Examples

The following code example displays a message when the document is closed. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentCloseEvent()
{
    this.CloseEvent += new Microsoft.Office.Interop.Word.DocumentEvents2_CloseEventHandler(ThisDocument_CloseEvent);
}

void ThisDocument_CloseEvent()
{
    MessageBox.Show("The document is closing.");
}
Private Sub DocumentCloseEvent()
    AddHandler Me.CloseEvent, AddressOf ThisDocument_CloseEvent
End Sub
Sub ThisDocument_CloseEvent()
    MessageBox.Show("The document is closing.")
End Sub

Applies to