Share via


WebFiles Collection

SharePoint Designer Developer Reference

A collection of WebFile objects. Each WebFile object represents all of the open files in a Web site. The WebFile object is a member of the WebFiles collection.

Remarks

Use the Files property to return the WebFiles collection. The following statement returns the WebFile objects in the WebFiles collection.

Visual Basic for Applications
Set myWebFiles = Application.Webs(0).RootFolder.Files

Use WebFiles(index), where index is the ordinal number of an item in the WebFiles collection, to return a single WebFile object. The following statement returns the first WebFile object in the collection.

Visual Basic for Applications
Set myWebFile = ActiveWeb.RootFolder.Files(0)

Use the Add method to add a WebFile object to the WebFiles collection. The following statement adds a new WebFile object to the collection of WebFile objects.

Visual Basic for Applications
myWebFiles.Add ("C:\New Web WebFiles\Sales Statistics.htm")

Use the Application property to return the Application object from within the WebFiles collection. The following statement returns the Application object from the WebFiles collection.

Visual Basic for Applications
myApp = ActiveWeb.RootFolder.Files.Application

Use the Count property to return the number of open files in the WebFiles collection. The following statement returns the number of files in the WebFiles collection.

Visual Basic for Applications
myCount = Webs(0).RootFolder.WebFiles.Count

Use the Delete method to delete a WebFile object. The following statement deletes the third file in the WebFiles collection.

Visual Basic for Applications
Webs(0).RootFolder.Files(2).Delete

Use the Parent property when you want to return the container for the WebFiles collection. The following statement returns the URL of the folder for the second file in the active Web site.

Visual Basic for Applications
myWebFileParent = ActiveWeb.RootFolder.Files(1).Parent.Url

See Also