OnAfterWebPublish Event Example

This example creates a property with the value of True after a web has been published.

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

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

Private Sub cmdPublishWeb_Click()
ActiveWeb.Publish "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_OnAfterWebPublish section of the code window. This code adds a property called Published to the web that contains the value True.

Private Sub eFPApplication_OnAfterWebPublish(ByVal pWeb As Web, Success As Boolean)
If Success = True Then
    pWeb.Properties.Add "Published", True
    pWeb.Properties.ApplyChanges
Else: MsgBox "There was a problem publishing your " & pWeb & " web."
End If
End Sub