Skip to main content

FileSystemObject.CreateFolder method

Table of contents
  1. Syntax
  2. Remarks
  3. Examples

Creates a folder.

Syntax

object.CreateFolder (foldername)

The CreateFolder method has these parts:

Part Description
object Required. Always the name of a FileSystemObject.
foldername Required. String expression that identifies the folder to create.

Remarks

An error occurs if the specified folder already exists.

Examples

The following code illustrates the use of the CreateFolder method.

Sub CreateFolderDemo()
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    
    'Create a new folder: TEST
    fso.CreateFolder "D:\Temp\TEST"
End Sub

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>