OnAfterPageSave Event Example

This example displays a message box after the page has been saved and displays the file name of 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 cmdSave, and a button called cmdCancel. Add the following code to the Declarations section of the form code window.

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindow

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 cmdSave_Click section of the code window.

Private Sub cmdSave_Click()
Dim myPageWindow As PageWindow

Set myPageWindow = ActiveWeb.ActiveWebWindow.ActivePageWindow
myPageWindow.Save
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_OnAfterPageSave section of the code window.

Private Sub eFPApplication_OnAfterPageSave(ByVal pPage As _
    PageWindow, Success As Boolean)
If Success = True Then
    MsgBox "The following page was saved: " & pPage.File.Name
Else: MsgBox "There was a problem with saving your page: " & _
    pPage.File.Name
End If
End Sub