MkDir

kirkm

Registered User.
Local time
Today, 17:59
Joined
Oct 30, 2008
Messages
1,257
I found this via Google which explains the error I have -
If path is a complex directory structure, the high-level directories must already exist or the MkDir statement will raise an error. For example, if you executed the following code:
MkDir "c:\Test\Access" The c:\Test directory must already exist. The MkDir statement will only attempt to create the Access directory under the c:\Test directory. It will not create the c:\Test directory itself.

Right - so is there another command that will create all of Path where needed?
Thanks
 
you can if you will make a UDF, like
this one:
Code:
Public Sub QuickMkDir(ByVal strPath As String)
'
' arnelgp
'
' purpose:  Create new folder even if the
'           parent folder has not been
'           created yet.
'
' example:  QuickMKDir "D:\Employees\Active\AgPuzon
'
    Dim var1 As Variant
    Dim var2 As Variant
    Dim strDirToMake As String
    On Error Resume Next
    var1 = Split(strPath, "\")
    For Each var2 In var1
        strDirToMake = strDirToMake & var2
        MkDir strDirToMake
        strDirToMake = strDirToMake & "\"
    Next
End Sub
 
Plog, you are correct...BUT...thanks to ChrisO (deceased member) and Pbaldy whom he entrusted his files to, there is a real slick UDF that does exactly what the OP wants to do.

It’s pretty geeky but it works a treat once you get it worked out:
http://www.baldyweb.com/Samples/MakeDirectory.zip

Let’s us know how it works out for you.
 

Users who are viewing this thread

Back
Top Bottom