Name

Folders Collection Object

Createable

No

Returned by

Folder.SubFolders property

Library

Microsoft Scripting Runtime

Description

The Folders collection object is a container for Folder objects. Normally, you’d expect to access a single object from the collection of that object; for example, you’d expect to access a Folder object from the Folders collection object. However, things are the other way around here: you access the Folders collection object from an instance of a Folder object. This is because the first Folder object you instantiate from the Drive object is a Root Folder object, and from it you instantiate a subfolders collection. You can then instantiate other Folder and subfolder objects to navigate through the drive’s filesystem.

The Folders collection is a subfolder of any Folder object. For instance, the top-level Folders collection (representing all of the folders in the root directory of a particular drive) can be can be instantiated as follows:

Dim oFS, oFolders
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolders = oFS.Drives("C").RootFolder.SubFolders

The Folders collection object is one of the objects in the File System object model; see the File System object model entry for an overview of the model, including the library reference needed to access it.

Properties

Item

Data Type: Folder object

Retrieves a particular Folder object from the Folders collection object. You can access an individual folder object by providing the exact name of the folder without its ...

Get VBScript in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.