Share via


DocumentAdded Event [Visio 2003 SDK Documentation]

Occurs after a document is opened or created.

Version added

4.1

Remarks

You can only handle the DocumentAdded event with an Event object that you create using the Add or AddAdvise method. See those method topics for details about the correct syntax.

You can add DocumentAdded events to the EventList property of Application, Documents, or Document objects. The first two are straightforward; if a document is opened or created in the scope of the Application object or its Documents collection, the DocumentAdded event occurs.

However, adding a DocumentAdded event to the EventList property of a Document object makes sense only if the event's action is visActCodeRunAddon. In this case, the event is persistable; it can be stored with the document. If the document that contains the persistent event is opened, its action is triggered. If a new document is based on or copied from the document that contains the persistent event, the DocumentAdded event is copied to the new document and its action is triggered. However, if the event's action is visActCodeAdvise, that event is not persistable and therefore is not stored with the document; hence, it is never triggered.

You can prevent code from running in response to the DocumentCreated, DocumentOpened, or DocumentAdded event and all events from firing by setting the value of the EventsEnabled property of an Application object to False.