OnWebOpen Event

       

Occurs when a web is opened.

Private Sub Application_OnWebOpen(ByVal pWeb As Web)

pWeb   Required WebEx. A WebEx object.

Remarks

The OnWebOpen event is associated with the Application object. When the user opens a web in Microsoft FrontPage, the OnWebOpen event fires and executes the code that you specified within the event procedure.

Example

This example opens the Index.htm file when a web is opened.

Note   This example uses Rogue Cellars as the specified web to be opened. You can create a web called Rogue Cellars or you can substitute a web of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdOpenWeb, 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 cmdOpenWeb_Click section of the code window.

Private Sub cmdOpenWeb_Click()
    Webs.Open ("file:///C:/My Documents/My Webs/Rogue Cellars")
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_OnWebOpen section of the code window.

Private Sub eFPApplication_OnWebOpen(ByVal pWeb As Web) 
    Dim myFile As WebFile

    Set myFile = pWeb.RootFolder.Files.Add("index.htm")
    myFile.Open
End Sub