Occurs before a page is saved.
Private Sub expression_OnBeforePageSave(ByVal pPage As PageWindowEx, SaveAsUI As Boolean, Cancel As Boolean
expression A variable name which references an object of type PageWindowEx declared using the WithEvents keyword in a class module.
pPage Required PageWindowEx. The specified PageWindowEx object.
SaveAsUI Required Boolean. True when the Save As dialog box is used to save a page. This can be the first time the page is saved or when the page is saved as a new page. False when when an existing page is saved.
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.
Remarks
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.
Example
The following 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 site and one open page within that site.
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 form code window.
Option Explicit
Private WithEvents eFPApplication As Application
Private Sub UserForm_Initialize()
Set eFPApplication = New Application
End Sub
Private Sub cmdSave_Click()
Dim myPageWindow As PageWindowEx
Set myPageWindow = ActiveWeb.ActiveWebWindow.ActivePageWindow
myPageWindow.Save
End Sub
Private Sub cmdCancel_Click()
'Hide the form.
frmLaunchEvents.Hide
Exit Sub
End Sub
Private Sub eFPApplication_OnBeforePageSave(ByVal pPage As _
PageWindowEx, 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