Private Sub Document_BeforeClose(Cancel As Boolean)
Cancel 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