I attempting to run vba code to create a directory from a cell.
This code worked when last run. Now, when I attempt to run it, I keep getting run time error 52 ("Bad file name or number").
there is no network failure.
The target directory does exist, and I have write access.
No "," or "()/:" in te selected cel
Any suggestions?????
CODE:
Sub Create_Folders()
BrowseForFolder = "N:\PR\Planning"
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
Sheets("Create dir").Select
Range("B6").Select
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then <--- this line is markt if i look at Debug
MkDir (BrowseForFolder & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
Sheets("Overzicht").Select
MsgBox " " & BrowseForFolder & Rng(r, c), vbInformation, "Created Directory:" & Rng(r, c)
End Sub
This code worked when last run. Now, when I attempt to run it, I keep getting run time error 52 ("Bad file name or number").
there is no network failure.
The target directory does exist, and I have write access.
No "," or "()/:" in te selected cel
Any suggestions?????
CODE:
Sub Create_Folders()
BrowseForFolder = "N:\PR\Planning"
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
Sheets("Create dir").Select
Range("B6").Select
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then <--- this line is markt if i look at Debug
MkDir (BrowseForFolder & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
Sheets("Overzicht").Select
MsgBox " " & BrowseForFolder & Rng(r, c), vbInformation, "Created Directory:" & Rng(r, c)
End Sub