WebWindows Collection Object

See Also         Properties         Methods        

Application object
WebWindows collection (WebWindow)

A collection of WebWindow objects. Each WebWindow object represents an open window in Microsoft FrontPage. The WebWindow object is a member of the WebWindows collection.

Using the WebWindows Collection

Use Items(index), where index is the index number of an item in the WebWindows collection, to return a single WebWindow object. The following example returns the Caption property for the fourth item in the WebWindows collection.

Function ReturnWebWindowCaption() As String
Dim myCaption As String
Dim myWebWindow As WebWindow

Set myWebWindow = Application.WebWindows(3)
myCaption = myWebWindow.Caption
ReturnWebWindowCaption = myCaption
End Sub

Use the WebWindows property to return the WebWindows collection. The following example closes all of the open WebWindow objects in the WebWindows collection, except the ActiveWebWindow object.

Private Sub CloseWebWindows
Dim myWebWindows As WebWindows
Dim myWebWindow As WebWindow
Dim myActiveWebWindow As WebWindow

Set myWebWindows = Application.WebWindows
Set myActiveWebWindow = ActiveWebWindow

For Each myWebWindow In myWebWindows
    If myWebWindow.Caption <> myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
End Sub

Use the Application property to return the Application object. If you're already working with the WebWindows collection and you'd like to check the version number of the application, you can easily access it from within your With myWebWindows statement as shown in the following example.

With myWebWindows
    myWebWindowCount = myWebWindows.Count
    myAppVersion = .Application.Version
    If myAppVersion < "4.0" Then
        MsgBox "Please upgrade your FrontPage software."
    Else
        For Each myWebWindow In myWebWindows
            myCaption = myWebWindow.Caption
            With myPageWindows
                myPageCount = PageWindows.Count
            End With
        Next
    End If
End With

You can use the Close method to close an individual WebWindow object, multiple WebWindow objects, or all WebWindow objects in a web. For more details on the Close method, see the usage described in the following table.

Important   FrontPage will close the application if you use the Close method to close all WebWindow objects in FrontPage.

Close Method Usage Code
Close an individual WebWindow object in the application
Application.WebWindows(index).Close
or
Application.WebWindows.Close(index)
Close multiple WebWindow objects in the application (as shown in the previous example)
For Each myWebWindow In myWebWindows
    If myWebWindow.Caption <> _
        myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
Close all WebWindow objects in the application
Application.WebWindows.Close
Close an individual WebWindow object in a web
Webs(index).WebWindows(index).Close
Close multiple WebWindow objects in a web
Set myWeb = Web(index).WebWindows
For Each myWebWindow In myWebWindows
    If myWebWindow.Caption _
      <> myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next
Close a collection in a web
Webs(index).WebWindows.Close
Closing all WebWindow objects in FrontPage functions the same as the Quit method The expression, Application.WebWindows.Close is the same as, Application.Quit.

Use the Count property to return the number of WebWindow objects in the collection. The following example returns the number of WebWindow objects.

Web.WebWindows.Count

Use the Parent property when you want to return the container for the WebWindows collection. The following statement returns the Application object.

Application.WebWindows.Parent.Name