Reputation: 11
I have a VBA
code for Excel to print quadruplicate copies on the default printer.
What I want is to save this quadruplicate as a single PDF file i.e all four sheets in a single continuous 4 pages PDF file.
The code is as below.
Sub PrintInvoiceQuadtriplicate()
Dim i As Integer
Dim VList As Variant
VList = Array("ORIGINAL FOR RECIPIENT", "DUPLICATE FOR TRANSPORTER", "TRIPLICATE FOR SELLER", "EXTRA COPY")
For i = LBound(VList) To UBound(VList)
Range("L1") = VList(i)
ActiveSheet.PrintOut
Next
End Sub
Kindly let me know how to modify this code to get a single PDF file instead of separate pages.
Upvotes: 1
Views: 921
Reputation: 1340
As said by Zac, possible duplicate with this post which has been answered.
Seems like you have to select your sheets before exporting as a PDF.
ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\tempo.pdf", Quality:= xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Credit @Tim Williams for his answer.
Upvotes: 1