MkDir - "Path Not Found"

mancitystu

New Member
Joined
Jul 7, 2016
Messages
2
Hi,

I am trying to create folders and sub folders if they don't already exist. Everything I try comes up with the runtime error 76 - Path Not Found",

Any ideas?

Thanks

SharePointPath = "C:\Temp\RBB Test\"

'Calculate how many reports to generate
CRows = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row

'Start main loop down the control sheet
For P = 6 To CRows

'Set Excel to the control sheet and range
Sheets("Control").Select
Range("A" & 1 + P).Select

'Odd looking code that generates the output file path and creates missing folders
'I don't think this is working as required.
'Doesn't generate top level folders e.g. NETWORK
Path = SharePointPath
inFileNo = ActiveCell.Value
InName = ActiveCell.Offset(0, 1).Value
Func = ActiveCell.Offset(0, 2).Value
PDFFileName = InName & "_Trend_" & Period & ".pdf"
Folder1 = ActiveCell.Offset(0, 3).Value
Folder2 = ActiveCell.Offset(0, 4).Value
Folder3 = ActiveCell.Offset(0, 5).Value
Folder4 = ActiveCell.Offset(0, 6).Value
Folder5 = ActiveCell.Offset(0, 7).Value
Folder6 = ActiveCell.Offset(0, 8).Value
If (Folder1 <> "" Or Folder1 <> Empty) Then
Path = Path & Folder1 & "\"
End If
If (Folder2 <> "" Or Folder2 <> Empty) Then
Path = Path & Folder2 & "\"
End If
If (Folder3 <> "" Or Folder3 <> Empty) Then
Path = Path & Folder3 & "\"
End If
If (Folder4 <> "" Or Folder4 <> Empty) Then
Path = Path & Folder4 & "\"
End If
If (Folder5 <> "" Or Folder5 <> Empty) Then
Path = Path & Folder5 & "\"
End If
If (Folder6 <> "" Or Folder6 <> Empty) Then
Path = Path & Folder6 & "\"
End If
If Dir(Path, vbDirectory) = "" Then
MkDir (Path)
Sheets("Control").Select
Range("A" & 1 + P).Select
ActiveCell.Interior.Color = vbRed
End If
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi

If more than one of your Folder cells are not blank your Path becomes concatenated!

hth
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top