Share via


Document.CloseEvent Event (2007 System)

Occurs when the document is closed.

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

Syntax

'Declaration
Public Event CloseEvent As DocumentEvents2_CloseEventHandler
'Usage
Dim instance As Document 
Dim handler As DocumentEvents2_CloseEventHandler 

AddHandler instance.CloseEvent, handler
public event DocumentEvents2_CloseEventHandler CloseEvent
public:
 event DocumentEvents2_CloseEventHandler^ CloseEvent {
    void add (DocumentEvents2_CloseEventHandler^ value);
    void remove (DocumentEvents2_CloseEventHandler^ value);
}
JScript does not support events.

Examples

The following code example displays a message when the document is closed.

This example is for a document-level customization.

Private Sub DocumentCloseEvent()
    AddHandler Me.CloseEvent, AddressOf ThisDocument_CloseEvent
End Sub 
Sub ThisDocument_CloseEvent()
    MessageBox.Show("The document is closing.")
End Sub
private void DocumentCloseEvent()
{
    this.CloseEvent += new Microsoft.Office.Interop.Word.DocumentEvents2_CloseEventHandler(ThisDocument_CloseEvent);
}

void ThisDocument_CloseEvent()
{
    MessageBox.Show("The document is closing.");
}

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace