Sub PrintScreen()
Dim FilePath As String
Dim FileName As String
Dim FullPath As String
Dim wsOriginal As Worksheet
Dim wsDuplicate As Worksheet
Dim wsTriplicate As Worksheet
' Define the folder path to save the combined PDF (you can modify this path)
FilePath = "D:\PES\P.E.S\invoice\Oct.24\pdf oct24\" ' Modify as needed
' Set the file name for the combined PDF
FileName = "Invoice_Combined.pdf"
' Full path of the PDF
FullPath = FilePath & FileName
' Copy the active sheet for each print version
Set wsOriginal = ActiveSheet
wsOriginal.Copy After:=wsOriginal ' Create the Original copy first
Set wsDuplicate = ActiveSheet ' Create the Duplicate copy second
wsDuplicate.Copy After:=wsDuplicate ' Create the Triplicate copy last
Set wsTriplicate = ActiveSheet
' Set the headers for each version
wsOriginal.PageSetup.RightHeader = "ORIGINAL FOR RECIPIENT"
wsDuplicate.PageSetup.RightHeader = "DUPLICATE FOR TRANSPORTER"
wsTriplicate.PageSetup.RightHeader = "TRIPLICATE FOR SUPPLIER"
' Select the sheets in the correct order: Original, Duplicate, Triplicate
Worksheets(Array(wsOriginal.Name, wsDuplicate.Name, wsTriplicate.Name)).Select
' Export the sheets as a single PDF in the correct order
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FullPath,
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False,
OpenAfterPublish:=False
' Delete the duplicate sheets after export
Application.DisplayAlerts = False
wsDuplicate.Delete
wsTriplicate.Delete
Application.DisplayAlerts = True
End Sub