Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Close Event

Occurs when a document is closed.

Private Sub Document_Close()

Remarks

If the event procedure is stored in a template, the procedure will run when a new document based on that template is closed and when the template itself is closed (after being opened as a document).

For information about using events with a Document object, see Using Events with the Document Object.

Example

This example makes a backup copy of the document on a file server when the document is closed. (The procedure can be stored in the ThisDocument class module of a document or its attached template.)

Private Sub Document_Close()
    ThisDocument.Save
    ThisDocument.SaveAs "\\network\backup\" & ThisDocument.Name
End Sub
Show:
© 2015 Microsoft