L
Legacy 436357
Guest
Hi,
I have this code for file path for the Invoice PDF.
Within the 'Invoices' folder I have years like 2019, 2020, 2021, etc. Then within those folders I have 12 folders Jan, Feb, Mar, etc.
Can the code be altered so the PDFs are saved to the proper sub folders by Month and Year?
Thank you
I have this code for file path for the Invoice PDF.
Code:
Private Sub CommandButton1_Click()
Dim NxtRw As Long, CurrentPath As String, wFile As String
On Error GoTo EnEvents
If Range("J3").Value = "" Then
NxtRw = 3
Else
NxtRw = Range("J2").End(xlDown).Offset(1).Row
End If
Application.EnableEvents = False
Range("J" & NxtRw).Value = Range("H6").Value
Range("K" & NxtRw).Value = Range("H3").Value
Range("L" & NxtRw).Value = Format(Now(), "mm/dd/yyyy HH:MM:SS")
MonthFolder = Format(Now, "MMM")
CurrentPath = "C:\Users\BPeterson\Google Drive\Invoices\" & MonthFolder & "\"
wFile = [H2] & " " & [H3] & " " & Format(Now(), "mm-dd-yyyy HH.MMam/pm") & ".pdf" 'must be hypen
Range("B2:H53").ExportAsFixedFormat Type:=xlTypePDF, Filename:=CurrentPath & wFile, _
Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
EnEvents:
Application.EnableEvents = True
End Sub
Within the 'Invoices' folder I have years like 2019, 2020, 2021, etc. Then within those folders I have 12 folders Jan, Feb, Mar, etc.
Can the code be altered so the PDFs are saved to the proper sub folders by Month and Year?
Thank you