zedmekis
Feb 03, 2024Copper Contributor
print a pdf in specific order
Hi, I coded a excel to be able to import a number of information (client page num and so on) and the code order the client in a specific order then I made a button to send a print to the pdf to be able to print all pages in a specific order. the code is working the pages orinted in the right order but it didn't print the pdf even with the right path it print the excel files I would like to know where is the problem
here's the code for the VB :
Sub PrintPDFWithCustomOrder()
Dim pdfPrintOrder As Variant
pdfPrintOrder = Array(2, 1, 10, 4)
Dim pdfFilePath As String
pdfFilePath = "C:\Path\document.pdf"
Dim pdfApp As Object
Set pdfApp = CreateObject("AcroExch.App")
Dim pdfDoc As Object
Set pdfDoc = CreateObject("AcroExch.PDDoc")
If pdfDoc.Open(pdfFilePath) Then
For Each page In pdfPrintOrder
pdfDoc.PrintPages page, page
Next page
pdfDoc.Close
End If
Set pdfDoc = Nothing
Set pdfApp = Nothing
End Sub