OnWebClose Event

Microsoft FrontPage Visual Basic

Occurs when a Web site is closed.

Private Sub expression_OnWebClose(ByVal pWeb As WebEx, Cancel As Boolean)

expression     An object of type Application declared using the WithEvents keyword in a class module.

pWeb    Required WebEx. A WebEx object.

Cancel    Required Boolean. True if the closing process was cancelled through the user interface, or if Cancel was set to True. Default is False.

Remarks

The OnWebClose event is associated with the Application object. When you close a Web site, the OnWebClose event fires and executes the code that you specified within the event procedure.

Example

The following example iterates through the open pages and, if necessary, saves them before the Web site is closed.

Note  To run this example, you must have at least one open Web site and one open page within that Web site. This example uses Rogue Cellars as the specified Web site. You can create a Web site called Rogue Cellars or substitute a Web site of your choice.

Create a form called frmLaunchEvents.frm and add two buttons, a button called cmdCloseWeb, 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 cmdCloseWeb_Click()
    Webs("C:/My Documents/My Web Sites/Rogue Cellars").Close
End Sub

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

		
Private Sub eFPApplication_OnWebClose(ByVal pWeb As WebEx, _
        Cancel As Boolean)
    Dim myPageWindows As PageWindows
    Dim myPageWindow As PageWindowEx

    Set myPageWindows = pWeb.ActiveWebWindow.PageWindows

    For Each myPageWindow In myPageWindows
        If myPageWindow.IsDirty = True Then myPageWindow.Save
    Next
End Sub