Folder object

Provides access to all the properties of a folder.

Remarks

The following code illustrates how to obtain a Folder object and how to return one of its properties.

Sub ShowFolderInfo(folderspec)
    Dim fs, f, s,
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(folderspec)
    s = f.DateCreated
    MsgBox s
End Sub

Collections

Collection Description
Files Returns a collection of all the files in a specified folder.
Folders Collection of all Folder objects contained within a Folder object.

Methods

Method Description
AddFolders Adds a new Folder to a Folders collection.
Copy Copies a specified folder from one location to another.
CreateTextFile Creates a new text file in the specified folder and returns a TextStream object to access the file.
Delete Deletes a specified folder.
Move Moves a specified folder from one location to another.

Properties

Property Description
Attributes Sets or returns the attributes of a specified folder.
DateCreated Returns the date and time when a specified folder was created.
DateLastAccessed Returns the date and time when a specified folder was last accessed.
DateLastModified Returns the date and time when a specified folder was last modified.
Drive Returns the drive letter of the drive where the specified folder resides.
Files Returns a Files collection consisting of all File objects contained in the specified folder, including those with hidden and system file attributes set.
IsRootFolder Returns True if a folder is the root folder and False if not.
Name Sets or returns the name of a specified folder.
ParentFolder Returns the parent folder of a specified folder.
Path Returns the path for a specified folder.
ShortName Returns the short name of a specified folder (the 8.3 naming convention).
ShortPath Returns the short path of a specified folder (the 8.3 naming convention).
Size Returns the size of a specified folder.
SubFolders Returns a Folders collection consisting of all folders contained in a specified folder, including those with Hidden and System file attributes set.
Type Returns the type of a specified folder.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.