Hi ALL,
I am using this macro to print the invoices in the separate PDF file.
Please can someone modify to code to print the all invoices in one PDF file.
Sub PrinttoPdf1()
Dim i As Integer
Dim Startrange As Integer
Dim Endrange As Integer
Dim PSh As Worksheet
Dim PPath As String
On Error GoTo errHandler
Set PSh = Sheets("Inv BCC")
Startrange = PSh.Range("M2").Value
Endrange = PSh.Range("N2").Value
PPath = PSh.Range("o2").Value
For i = Startrange To Endrange
PSh.Range("h14").Value = PSh.Range("n12").Offset(i, 0).Value
Printfile = PSh.Range("h14").Value
PSh.Range("A1:I37").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=PPath & Printfile & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file" & vbNewLine & vbNewLine & "Please check the input parameters & print location" & vbNewLine & "Please double check if the file location exists and is in correct format" & vbNewLine & vbNewLine & "C:\PDF Export\May2018"
Resume exitHandler
End Sub
I am using this macro to print the invoices in the separate PDF file.
Please can someone modify to code to print the all invoices in one PDF file.
Sub PrinttoPdf1()
Dim i As Integer
Dim Startrange As Integer
Dim Endrange As Integer
Dim PSh As Worksheet
Dim PPath As String
On Error GoTo errHandler
Set PSh = Sheets("Inv BCC")
Startrange = PSh.Range("M2").Value
Endrange = PSh.Range("N2").Value
PPath = PSh.Range("o2").Value
For i = Startrange To Endrange
PSh.Range("h14").Value = PSh.Range("n12").Offset(i, 0).Value
Printfile = PSh.Range("h14").Value
PSh.Range("A1:I37").ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=PPath & Printfile & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next i
exitHandler:
Exit Sub
errHandler:
MsgBox "Could not create PDF file" & vbNewLine & vbNewLine & "Please check the input parameters & print location" & vbNewLine & "Please double check if the file location exists and is in correct format" & vbNewLine & vbNewLine & "C:\PDF Export\May2018"
Resume exitHandler
End Sub