Hi,
I'm using the code from this thread below:
I'm able to create a pdf file from a specific excel range name, but I need help to write code in order to merge the all distiller files into one single pdf file.
Thanks.
Dim PSFileName As String, PSFile As String
Dim PDFFileName As String
Dim fs As FileSystemObject
Dim NewPs As Variant
PSFile = "C:\myPostScript_"
PDFFileName = "C:\myPDF.pdf"
' Print the Excel range to the postscript file
Dim MySheet As Worksheet
Set MySheet = ActiveSheet
For i = 1 To 2
Print_Sel = "PrintSel_" & i
PSFileName = PSFile & i & ".ps"
MySheet.Range(Print_Sel).PrintOut copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=False, collate:=True, prtofilename:=PSFileName
Next i
''''Here - I don't know how to merge PSFileName1 and PSFileName2 into one single PDF file.
' Convert the postscript file to .pdf
Dim mypdf As PdfDistiller
Set mypdf = New PdfDistiller
mypdf.FileToPDF PSFileName, PDFFileName, ""
'''''''''''''''''''
' Delete ps - distiller files - after pdf is created.
Set fs = New FileSystemObject
With New FileSystemObject
For i = 1 To 2
PSFileName = PSFile & i & ".ps"
.DeleteFile PSFileName
Next i
End With
I'm using the code from this thread below:
I'm able to create a pdf file from a specific excel range name, but I need help to write code in order to merge the all distiller files into one single pdf file.
Thanks.
Dim PSFileName As String, PSFile As String
Dim PDFFileName As String
Dim fs As FileSystemObject
Dim NewPs As Variant
PSFile = "C:\myPostScript_"
PDFFileName = "C:\myPDF.pdf"
' Print the Excel range to the postscript file
Dim MySheet As Worksheet
Set MySheet = ActiveSheet
For i = 1 To 2
Print_Sel = "PrintSel_" & i
PSFileName = PSFile & i & ".ps"
MySheet.Range(Print_Sel).PrintOut copies:=1, preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=False, collate:=True, prtofilename:=PSFileName
Next i
''''Here - I don't know how to merge PSFileName1 and PSFileName2 into one single PDF file.
' Convert the postscript file to .pdf
Dim mypdf As PdfDistiller
Set mypdf = New PdfDistiller
mypdf.FileToPDF PSFileName, PDFFileName, ""
'''''''''''''''''''
' Delete ps - distiller files - after pdf is created.
Set fs = New FileSystemObject
With New FileSystemObject
For i = 1 To 2
PSFileName = PSFile & i & ".ps"
.DeleteFile PSFileName
Next i
End With