Microsoft® Visual Basic® Scripting Edition
Add Method (Folders)
 Language Reference 
Version 3 

See Also                    Applies To


Description
Adds a new Folder to a Folders collection.
Syntax
object.Add(folderName)

The Add method has the following parts:

Part Description
object Required. Always the name of a Folders collection.
folderName Required. The name of the new Folder being added.

Remarks
The following example illustrates the use of the Add method to add a new folder:
Sub AddNewFolder(path, folderName)
  Dim fso, f, fc, nf
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set f = fso.GetFolder(path)
  Set fc = f.SubFolders
  If folderName <> "" Then
    Set nf = fc.Add(folderName)
  Else
    Set nf = fc.Add("New Folder")
  End If
End Sub
An error occurs if folderName already exists.