WebWindows Collection

SharePoint Designer Developer Reference

A collection of WebWindow objects.

Remarks

Each WebWindow object represents an open Web site in Office SharePoint Designer. The WebWindow object is a member of the WebWindows collection.

Use WebWindows(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.

Visual Basic for Applications
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.

Visual Basic for Applications
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 are working with the WebWindows collection and you want to check the version number of the application, you can easily access it by using the With myWebWindows statement as shown in the following example.

Visual Basic for Applications
With myWebWindows
    myWebWindowCount = myWebWindows.Count
    myAppVersion =.Application.Version
    If myAppVersion < "4.0" Then
        MsgBox "Please upgrade your 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 Office SharePoint Designer. For more details on the Close method, see the usage described in the following table.

Office SharePoint Designer closes the application if you use the Close method to close all WebWindow objects in Office SharePoint Designer.

Close Method Usage Code

Close an individual WebWindow object in the application

Visual Basic for Applications
Application.WebWindows(index).Close
or
Visual Basic for Applications
Application.WebWindows.Close(index)

Close multiple WebWindow objects in the application (as shown in the previous example)

Visual Basic for Applications
For Each myWebWindow In myWebWindows
    If myWebWindow.Caption <> _
        myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next

Close all WebWindow objects in the application

Visual Basic for Applications
Application.WebWindows.Close

Close an individual WebWindow object in a Web site

Visual Basic for Applications
Webs(index).WebWindows(index).Close

Close multiple WebWindow objects in a Web site

Visual Basic for Applications
Set myWebWindows = Web(index).WebWindows
For Each myWebWindow In myWebWindows
    If myWebWindow.Caption _
      <> myActiveWebWindow.Caption Then _
        myWebWindow.Close
Next

Close a collection in a Web site

Visual Basic for Applications
Webs(index).WebWindows.Close

Closing all WebWindow objects in Office SharePoint Designer 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.

Visual Basic for Applications
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.

Visual Basic for Applications
Application.WebWindows.Parent.Name

See Also