Document.BeforeClose event (Publisher)

Occurs immediately before any open document closes.

Syntax

expression.BeforeClose (Cancel)

expression A variable that represents a Document object.

Parameters

Name Required/Optional Data type Description
Cancel Required Boolean False when the event occurs. If the event procedure sets this argument to True, the document doesn't close when the procedure is finished.

Remarks

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

Example

This example prompts the user for a yes or no response before closing a document. For this example to work, you must place this code into the ThisDocument module.

Private Sub Document_BeforeClose(Cancel As Boolean) 
 Dim intResponse As Integer 
 
 intResponse = MsgBox("Do you really want to close " _ 
 & "the document?", vbYesNo) 
 
 If intResponse = vbNo Then Cancel = True 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.