Share via


Webs Collection

SharePoint Designer Developer Reference

A collection of Web objects.

Remarks

Each Web object represents a Web site, which can be either disk-based (on a local hard drive) or server-based (on a Web server). The Web object is a member of the Webs collection.

Use the Webs property to return the Webs collection. You can also use the Application property to return the Application object. The following statement uses the Application object to return the first item in the Webs collection or use the second statement to return the entire collection of Web sites.

Visual Basic for Applications
Set myWebOne = Application.Webs(0)
Set myWebs = Application.Webs

Use Webs(Index), where Index is the index number of an item in the Webs collection, to return a single Web object. The following statement returns the third Web site in the collection of open Web objects.

Visual Basic for Applications
Set myGetWebThree = Webs(2)

Use the Add method to add an item to the list of available items in the Webs collection. The following statement adds the Coho Winery Web site to the Webs collection. If it doesn't exist, Office SharePoint Designer creates a new Web site at the specified location and opens it.

Visual Basic for Applications
Webs.Add("C:\My Documents\My Web Sites\Coho Winery")

Use the Application property to return information about the application from within the Webs collection. The following statement returns the version number of the Application object.

Visual Basic for Applications
ActiveWeb.Webs.Application.Version

Use the Count property to return the number of open Web sites in the Webs collection. The following statement returns the number of open Web sites.

Visual Basic for Applications
Webs.Count

Use the Delete method to permanently delete a Web site from the Webs collection. The following statement deletes the Coho Winery Web site.

Visual Basic for Applications
Webs.Delete("C:\My Documents\My Web Sites\Coho Winery")

Use the Open method to open a Web site. The following statement opens a Web site and adds it to the collection of items in the Webs collection.

Visual Basic for Applications
Webs.Open("C:\My Documents\My Web Sites\Coho Winery")

Use the Parent method when you want to return the container of the Webs collection, which is the application. The following statement returns the Application object.

Visual Basic for Applications
Set myParent = Webs.Parent

See Also