DocumentBeforeClose Event Example

This example prompts the user for a yes or no response before closing any document.

Private Sub App_DocumentBeforeClose _
        (ByVal Doc As Document, _
        Cancel As Boolean)
    a = MsgBox("Do you really " _
        & "want to close the document?", _
        vbYesNo)
    If a = vbNo Then Cancel = True
End Sub