Share via


WebFiles Collection Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.


Aa190244.parchild(en-us,office.10).gifWebFiles
Aa190244.space(en-us,office.10).gifAa190244.parchild(en-us,office.10).gifWebFile

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 Files property to return the WebFiles collection. The following statement returns the WebFile objects in the WebFiles collection.

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

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

  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 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.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 second file in the active web.

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