If root directory is available and access is available to the user running the command then MkDir doesn't require folder existence check.A sample in this thread :VBA to create Folder Tree - Sub and Super Sub Folders
Hello Experts, List of activities in Column 'A' should be my 'Parent Folder' which are unique. I have listed sub and super sub folders which are common for all the unique 'Parent Folders' created above. Looking for a VB script where i can accomplish the job in one click. I'm looking for...chandoo.orgOr just create the folders in the sub level order via MkDir statement so without the previous link trickbut just checking before if a folder already exists via Dir function …
it's better to use the easy function MakeSureDirectoryPathExists when creating multiple sub levels at once
Private Declare PtrSafe Function MakeSureDirectoryPathExists% Lib "imagehlp.dll" (ByVal DirPath$)
Sub Demo2()
For R% = 11 To 19 Step 2: E% = E% + 1 - MakeSureDirectoryPathExists(Cells(R, 2)): Next
Application.Speech.Speak IIf(E, "Error!", "Done!"), True
End Sub
I have tested and therefore commented. However, we probably are referring to two different approaches. Mine is mkdir through cmd and you are approaching through VBA.shrivallabha, did you try at least ? MkDir raises an error when the folder already exists !As MkDir raises an error as well when one of the parents folder does not existso the reason why it's better to use the easy function MakeSureDirectoryPathExists when creating multiple sub levels at once …
RetVal = Shell("cmd.exe /c mkdir " & Chr(34) & FldPath & Chr(34), 1)
For R% = 11 To 19 Step 2: Shell "cmd.exe /c mkdir """ & Cells(R, 2) & """", 0: Next