I am using the code below to convert worksheets into PDFs and then automatically save them to a specified location on a network drive. The code currently requires the folders [to which the PDFs are being saved] to already exist. What if I do not want to create the folders in advance? I built the workbook to be able to used for the next 20 years and I don't really feel like making 520 folders. Can I modify the macro to CREATE the folder if it does not already exist? In this case, when the button is pushed, it looks for the subfolder "070112 - 071412" within G:\Timesheets\PDF Archive\2013\ and saves the PDF to it. If the subfolder "070112 - 071412" is not already there, can the code create the folder and then save the PDF to it?
Sub sendpdf01()
'
' sendpdf01 Macro
'
'
Dim pw As String
pw = Application.InputBox("Enter password")
Select Case pw
Case "6566"
'run code
Case Else
Exit Sub
End Select
ActiveSheet.Unprotect pw
Range("B4:O30").Select
Selection.Locked = True
Selection.FormulaHidden = True
Range("A1:O1").Select
Range("B4:O29").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorDark2
.TintAndShade = -9.99786370433668E-02
.PatternTintAndShade = 0
End With
Range("A1:O1").Select
ActiveSheet.Protect pw
Dim FileName As String
FileName = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 5)
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"G:\Timesheets\PDF Archive\" & Worksheets("Menu").Range("F6") & "\" & _
Worksheets("Menu").Range("B9") & "\" & FileName & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Range("A1:O1").Select
ActiveWorkbook.Save
End Sub
Bookmarks