OnBeforeWebPublish Event

Microsoft FrontPage Visual Basic

Occurs before a Web site is published.

Private Sub expression_OnBeforeWebPublish(ByVal pWeb As WebEx, Destination As String, Cancel As Boolean)

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

pWeb    Required WebEx. The specified WebEx object.

Destination    Required String. The URL of the target location.

Cancel    Required Boolean. Causes Microsoft FrontPage to abort the publish when set to True. When Cancel is programmatically set to True, the user can abort the save process by clicking the Cancel button on the form. Default is False.

Remarks

The OnBeforeWebPublish event is associated with the Application object. When the user publishes a Web site in FrontPage, the OnBeforeWebPublish event fires and executes the code within the event procedure.

Example

The following example adds a copyright string to the index page of the specified Web site.

Note  To run this example, you must have at least one open Web site. This example uses a Web site called Rogue Cellars. You can create a Web site called Rogue Cellars or you can substitute a Web site of your choice in the following code sample.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdPublishWeb, 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 cmdPublishWeb_Click()
    ActiveWeb.Publish "C:\My Documents\My Web Sites\Rogue Cellars"
End Sub

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

		
Private Sub eFPApplication_OnBeforeWebPublish(ByVal pWeb As WebEx, _
        Destination As String, Cancel As Boolean)
    Dim myCopyright As String
    Dim myIndexFile As WebFile

    myCopyright = "Copyright 1999 by Rogue Cellars"
    Set myIndexFile = pWeb.RootFolder.Files("index.htm")
    myIndexFile.Open
    If myIndexFile.Application.ActiveDocument.body.outerText <> _
            myCopyright Then
        myIndexFile.Application.ActiveDocument.body.insertAdjacentText _
            "BeforeEnd", myCopyright
    End If
    ActivePageWindow.Close
End Sub