Both of the above posts mention the MkDir which is the correct function.
Please keep in mind that MkDir can only create one directory at a time, and the parent of that directory must already exists. me2you's example creates the directory off the root of the C: drive which is correct, but if you try:
[tt]
MkDir "C:\sub1\sub2\sub3\sub4\YourDir"
[/tt]
Then the sub1, sub2, sub3, and sub4 directories must already exist. If they don't, then you will have to build the entire directory tree in order before you can make YourDir.
Good Luck
--------------
To get the most from your Tek-Tips experience, please read FAQ181-2886 As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
Another way for creating any directory, provided no permission issue:
Sub myCreateFolder(strPath)
Set fso = CreateObject("Scripting.FileSystemObject")
tmpArr = Split(strPath, "\")
tmpPath = tmpArr(0)
For i = 1 To UBound(tmpArr)
If Not fso.FolderExists(tmpPath) Then
fso.CreateFolder tmpPath
End If
tmpPath = tmpPath & "\" & tmpArr(i)
Next
Set fso = Nothing
End Sub
Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.