WebFolders Collection






A collection of WebFolder objects. Each WebFolder object within the WebFolders collection represents a folder in a Web site. The WebFolder object is a member of the WebFolders collection.
Note All of the methods that involve changing the location of a folder, such as Copy or Move, only change the location within the current Web site; you cannot move a folder from one Web site to a another Web site.
Using the WebFolders object
Use WebFolders(index), where index is the index number of an item in the WebFolders collection, to return a single WebFolder object. The following example returns the first WebFolder object in the collection.
Set myFolder = ActiveWeb.RootFolder.Folders(0)
Use the Add method to add a new WebFolder object to the WebFolders collection in a Web site. Both of the following statements add a WebFolder to the collection of WebFolders in the active Web site
Note The FolderUrl argument within the quotes ("Coho Winery") should only include the new folder name, not the entire URL, unless you are adding a new URL to the location designated as the FolderUrl. The program will fail if the entire URL is included for existing URLs.
ActiveWeb.RootFolder.Folders.Add ("Coho Winery")
ActiveWeb.RootFolder.Folders.Add "Coho Winery"
Use the Count property to return the number of total navigation nodes in the WebFolders collection. The following statement returns the number of Web folders in the Coho Winery Web site.
Webs("C:\Web Server One\Coho Winery").Folders.Count
Use the Delete method to delete a folder from a Web site. The following statements delete the tenth WebFolder object. The second statement uses the name of the folder instead of the index number to designate the folder to delete.
ActiveWeb.RootFolder.Folders(9).Delete
ActiveWeb.RootFolder.Folders("TempFolder").Delete
Use the Copy method to copy a WebFolder object. The following example copies a folder (WebFolders(4)
) to another folder on the active Web site (Chardonnay Inventory). For purposes of this example, WebFolders(4)
is a folder named Inventory in the Coho Winery Web site. This folder contains the entire wine inventory
Private Sub CopyInventory()
Dim myFolder As WebFolder
Set myFolder = ActiveWeb.RootFolder.Folders(4)
myFolder.Copy ("C:\Coho Winery\Chardonnay Inventory, False, True)
End Sub
Use the Parent property when you want to return the container for the WebFolders collection. The following statement returns the container for the fourth folder.
myParent = Webs.RootFolder.Folders(3).Parent