Share via


WebFolders 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.


Aa190248.parchild(en-us,office.10).gifWebFolders
Aa190248.space(en-us,office.10).gifAa190248.parchild(en-us,office.10).gifWebFolder

A collection of WebFolder objects. Each WebFolder object within the WebFolders collection represents an open folder in a web. 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 you cannot change the location of a folder from the current web to a different web.

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. Both of the following statements add a WebFolder to the collection of WebFolders in the active web—parentheses are not required for the folder name, as shown in the second statement.

Note   The FolderUrl argument within the quotes ("Rogue Cellars") 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 ("Rogue Cellars")
ActiveWeb.RootFolder.Folders.Add "Rogue Cellars"

Use the Count property to return the number of total navigation nodes in the WebFolders collection. The following statement returns the number of webs in the Rogue Cellars web.

  Webs("C:\Web Server One\Rogue Cellars").Folders.Count

Use the Delete method to delete a WebFolder object from the collection of WebFolders. 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 (Chardonnay Inventory). For purposes of this example, WebFolders(4) is a folder in the Rogue Cellars web named Inventory. This folder contains the entire wine inventory—but the web designer wanted to feature the sale on Chardonnay wines, and so created a temporary folder that will be edited to contain only Chardonnay wine.

  Private Sub CopyInventory()
    Dim myFolder As WebFolder

    Set myFolder = ActiveWeb.RootFolder.Folders(4)

    myFolder.Copy ("C:\Rogue Cellars\Chardonnay Inventory, False, True)
End Sub

Use the Move method to move a folder from one location in a web to another. For example, if you had old advertising pages that you wanted to keep for the next quarter's sale, you could move them to another folder, as shown in the following example.

  Private Sub MoveOldAds()
    Dim myOldAds As WebFolder

    Set myOldAds = Webs(0).RootFolder.Folders(1)

    myOldAds.Move("C:\Rogue Cellars\FirstQtr Advertising", True, 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