Function File Names Class

MakeDirectory

Create the named directory even if the other directories along the path do not currently exist. Function returns True upon success and False if the directory cannot be created for any reason.

Signature (Visual Basic / VBA)

Public Function MakeDirectory( _
    ByVal vDirectory As Variant _
    ) As Variant

Code Example

    ' Example will create directory C:\TEMP\LEVEL2\LEVEL3
    ' even if it has to create C:\TEMP and C:\TEMP\LEVEL2
    MakeDirectory("C:\TEMP\LEVEL2\LEVEL3") = True

Parameters

Parameter Description
vDirectory Name of the directory that is to be created. Function returns Null if vDirectory is Null or cannot be fixed-up to a string.

Notes & Version History

Note If this function fails, it is usually because either 1) the drive is invalid, or 2) there is already a file whose name conflicts with some part of the path name vDirectory. For example, the above example would return False if there were no drive "C" or if there were already a file named "C:\TEMP", "C:\TEMP\LEVEL2", or "C:\TEMP\LEVEL2\LEVEL3".