Compartilhar via


Document.Open Event

Word Developer Reference

Occurs when a document is opened.

Syntax

Private Sub expression_Private Sub Document_Open

expression   A variable that represents a Document object.

Remarks

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

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

Example

This example displays a message when a document is opened. (The procedure can be stored in the ThisDocument class module of a document or its attached template.)

Visual Basic for Applications
  Private Sub Document_Open()
    MsgBox "This document is copyrighted."
End Sub

See Also