OnPageNew Event

Microsoft FrontPage Visual Basic

Occurs when a new page is created.

Private Sub expression_OnPageNew(ByVal pPage As PageWindowEx)

expression     The variable name of an object of type Application declared using the WithEvents keyword in a class module.

pPage    Required PageWindowEx. A PageWindowEx object.

Remarks

When the user creates a new page within a frameset, the OnPageNew event is only fired once— when the page containing the frameset tags is opened. Then Microsoft FrontPage executes the code within the event procedure.

Note  The OnPageNew event only fires for the default frameset, even if there are more frames on the page. This event only fires if FrontPage is in Page view. If FrontPage is in any other view, the OnPageNew event won't fire.

Example

The following example applies a theme to a new page.

Note  To run this example, you must have at least one open Web site. This example uses Rogue Cellars as the specified Web site and Zinfandel.htm as the specified page. You can create a Web site and page using these names or you can substitute a Web site and page of your choice.

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

Option Explicit
Private WithEvents eFPApplication As Application
Private pPage As PageWindowEx

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

		
Private Sub cmdAddPage_Click()
    Dim myPageWindows As PageWindows
    Dim myFile As String

    Set myPageWindows = ActiveWeb.ActiveWebWindow.PageWindows
    myFile = _
        "C:/My Documents/My Web Sites/Rogue Cellars/Zinfandel.htm"
    myPageWindows.Add (myFile)
End Sub

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

		
Private Sub eFPApplication_OnPageNew(ByVal pPage As PageWindowEx)
    pPage.ApplyTheme ("artsy")
End Sub