Occurs before a page is saved.
Private Sub Application_OnBeforePageSave(ByVal pPage As PageWindow, SaveAsUI As Boolean, Cancel As Boolean)
pPage Required PageWindowEx. The specified PageWindowEx object.
SaveAsUI Required Boolean. True for the first time the page has been saved. If SaveAsUI is True then the user used the SaveAs dialog box to save the page; if SaveAsUI is False, then the user used the Save dialog box to save an existing file.
Cancel Required Boolean. Causes Microsoft FrontPage to abort the save 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.
The OnBeforePageSave event is associated with the Application object. When the user saves a page or closes FrontPage, the OnBeforePageSave event fires and executes the code that you specified within the event procedure.
Note If you set Cancel to True, the page won't be saved.
This example displays a message box before the page has been saved and displays the document title of the file for 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 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 cmdSave_Click section of the code window.
Private Sub cmdSave_Click()
Dim myPageWindow As PageWindowEx
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_OnBeforePageSave section of the code window.
Private Sub eFPApplication_OnBeforePageSave(ByVal pPage As _
PageWindow, SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "The following page will be saved: " & pPage.File.Name _
& "will be saved with the title: " & pPage.Document.Title
End Sub