mkdir

P

Peter

Does anyone have any idea why this doesn't work? I keep getting a Path
not found (Error 76) message and the mkdir (save_path2) part of the
code highlighted.

If Dir(save_path2, vbDirectory) = "" Then MkDir (save_path2)

Thanks,

Peter
 
B

Bob Phillips

If Dir(save_path2, vbDirectory) = "" Then MkDir save_path2


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
U

urkec

Peter said:
Does anyone have any idea why this doesn't work? I keep getting a Path
not found (Error 76) message and the mkdir (save_path2) part of the
code highlighted.

If Dir(save_path2, vbDirectory) = "" Then MkDir (save_path2)

Thanks,

Peter

You can also check if the parent folder exists before you use MkDir

Sub test()

Set fso = CreateObject _
("Scripting.FileSystemObject")

save_path2 = "C:\blah\myDir"

parentFolder = fso.GetParentFolderName(save_path2)

If fso.FolderExists(parentFolder) _
And Not fso.FolderExists(save_path2) Then
MkDir save_path2
Else
MsgBox "Could not create folder"
End If

End Sub


Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top