Skip to Content
VB & VBA in a Nutshell: The Language
book

VB & VBA in a Nutshell: The Language

by Paul Lomax
October 1998
Intermediate to advanced
656 pages
16h 10m
English
O'Reilly Media, Inc.
Content preview from VB & VBA in a Nutshell: The Language
Folders.Add Method (VB6)

Syntax

oFoldersCollObj.Add newfoldername

oFoldersCollObj

Use: Required

Data Type: Folders collection object

Any object variable returning a Folders collection object.

newfoldername

Use: Required

Data Type: String

The name of the new folder.

Return Value

Folder object.

Description

Creates a new folder. The location of the new folder is determined by the parent to which the Folders collection object belongs. For example, if you are calling the Add method from a Folders collection object that is a child of the root Folder object, the new folder is created in the root (i.e., it's added to the root's subfolders collection). For example:

Dim oFileSys As New FileSystemObject
Dim oRoot As Folder, oChild As Folder
Dim oRootFolders As Folders

Set oRoot = oFileSys.Drives("C").RootFolder
Set oRootFolders = oRoot.SubFolders
Set oChild = oRootFolders.Add("Downloads")

Rules at a Glance

You can't use a path specifier in newfoldername ; you can use only the name of the new folder.

See Also

FileSystemObject.CreateFolder Method
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to VBA

Absolute Beginner's Guide to VBA

Paul McFedries
Visual Basic 2015 Unleashed

Visual Basic 2015 Unleashed

Alessandro Del Sole

Publisher Resources

ISBN: 1565923588Catalog PageErrata