Using Events with the Document Object
|Publisher Developer Reference|
The Document object supports seven events: BeforeClose , Open , Redo , ShapesAdded , ShapesRemoved , Undo , and WizardAfterChange . You write procedures to respond to these events in the class module named "ThisDocument." Use the following steps to create an event procedure.
- Under your publication project in the Project Explorer window, double-click ThisDocument. (In Folder view, ThisDocument is located in the Microsoft Publisher Objects folder.)
- Select Document from the Object drop-down list box.
- Select an event from the Procedure drop-down list box.
An empty subroutine is added to the class module.
- Add the Visual Basic instructions you want to run when the event occurs.
This example shows an Open event procedure that displays a message when a publication is opened.
The following example shows a BeforeClose event procedure that prompts the user for a yes or no response before closing a document.
|For information on creating event procedures for the Application object, see Using Events with the Application Object .|