Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MkDir runtime Error 76. Path Not Found 1

Status
Not open for further replies.

sna1maa14

Programmer
Nov 21, 2003
23
US
I'm trying to create a new folder if it does not exsit but I keep getting a runtime Error 76, Path Not Found. It only happens if I specify multiple folders ex. Mkdir "D:\Folder1\Folder2". If I put Mkdir "D:\Folder1" it works. What am I doing wrong.

Thanks
Sna1maa

 
To successfully create D:\Folder1\Folder2, D:\Folder1 must be an existing folder.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I was afraid you were going to say that. Thanks.
 
Brute force method.
In a standard code module create this procedure:
Code:
Sub myMkDir(strFolderName As String)
On Error Resume Next
Dim a, t As String, i As Integer
a = Split(strFolderName, "\")
t = a(0)
For i = 1 To UBound(a)
  t = t & "\" & a(i)
  MkDir t
Next
End Sub

Now, you can use this code (even if D:\Folder1 doesn't exists):
myMkDir "D:\Folder1\Folder2"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top