Occurs when a page is opened.
Private Sub Application_OnPageOpen(ByVal pPage As PageWindow)
pPage Required PageWindowEx. A PageWindowEx object.
The OnPageOpen event is associated with the Application object. When the user opens a page, Microsoft FrontPage opens the frameset for the page and fires the OnPageOpen event for the default frameset. Then FrontPage executes the code that you specified within the event procedure.
Note The OnPageOpen event only fires for the default frameset, even if there are more frames on the page.The OnPageOpen event only fires if the page is not open.
This example changes the title of the FPHTMLDocument object, when the document is opened in a PageWindowEx object.
Note To run this example, you must have at least one open web. This example uses Rogue Cellars as the specified web and Zinfandel.htm as the specified page. You can create a web and page using these names or you can substitute a web and page of your choice.
Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdOpenPage,
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
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 cmdAddPage_Click section of the code window.
Private Sub cmdAddPage_Click()
Dim myPageWindows As PageWindows
Dim myFile As String
Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
myFile = _
"file:///C:/My Documents/My Webs/Rogue Cellars/Zinfandel.htm"
myPageWindows.Add (myFile)
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_OnPageOpen section of the code window.
Private Sub eFPApplication_OnPageOpen(ByVal pPage As _
PageWindow)
Dim myDoc As FPHTMLDocument
Set myDoc = pPage.ActiveDocument
myDoc.Title = "Rogue Cellars Home Page"
End Sub