OnPageClose Event

       

Occurs when a page is closed.

Private Sub Application_OnPageClose(ByVal pPage As PageWindow, Cancel As Boolean)

pPage   Required PageWindowEx. The specified PageWindowEx object.

Cancel   Required Boolean. Causes Microsoft FrontPage to abort the close when set to True. When Cancel is programmatically set to True, the user can abort the save process by clicking the Cancel button on the form. Default is False.

Remarks

The OnPageClose event is associated with the Application object. When the user closes a PageWindowEx object, the OnPageClose event fires and executes the code that you specified within the event procedure.

Example

This example checks if a page has been modified and saves the page if the IsDirty property is True before closing the page.

Note   To run this example, you must have at least one open web and one open page within that web.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdClosePage, and a button called cmdCancel. Add the following code to the Declarations section of a form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindowEx

Add the following code to the UserForm_Initialize section of the code window.

Private Sub UserForm_Initialize()
    Set eFPApplication = New Application
End Sub

Add the following code to the cmdClosePage_Click section of the code window.

Private Sub cmdClosePage_Click()
    ActivePageWindow.Close
End Sub

Add the following code to the cmdCancel_Click section of the code window.

Private Sub cmdCancel_Click()
    'Hide the form.
    frmLaunchEvents.Hide
    Exit Sub
End Sub

Add the following code to the eFPApplication_OnPageClose section of the code window.

Private Sub eFPApplication_OnPageClose(ByVal pPage As _
        PageWindow, Cancel As Boolean)
    If pPage.IsDirty = True Then pPage.Save
End Sub