OnWebOpen Event 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 PageWindow

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