OnWebNew Event

       

Occurs when a new web is created.

Private Sub Application_OnWebNew(ByVal pWeb As Web)

pWeb   Required WebEx. A WebEx object.

Remarks

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

Example

This example creates a temporary web and adds 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 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 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