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
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