OnWebNew Event Example

This example creates a temporary web and adds and opens a new file.

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

Private Sub cmdCreateWeb_Click()
Webs.Add ("file:///C:/My Documents/My Webs/TempWeb")
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_OnWebNew section of the code window.

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

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