WebFiles Collection Object

See Also         Properties         Methods        

Application object
Webs object
Web object
RootFolder object
Files object

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

Using the WebFiles Object

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

Set myWebFiles = Application.Webs(0).RootFolder.WebFiles

Use WebFiles(index), where index is the index 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.

Set myWebFile = ActiveWeb.RootFolder.WebFiles(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 WebFiles.

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 within the WebFiles collection.

myApp = ActiveWeb.RootFolder.WebFiles.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 collection of WebFiles.

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.

Webs(0).RootFolder.WebFiles(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 second file in the active web.

myWebFileParent = ActiveWeb.RootFolder.WebFiles(1).Parent.Url