VBA Excel - Merge two PDFs with PDFCreator
Clemy
-
C-Claire Posted messages 4562 Registration date Status Member Last intervention -
C-Claire Posted messages 4562 Registration date Status Member Last intervention -
Hello,
I'm trying to create a macro to merge two PDF documents but it's not working. Could someone help me? Here’s the macro:
Sub testPrintPDF()
Dim OLDPRINTER As String
Dim FILE As String 'Link to the folder where the PDFs are located
Dim SCOPE1 As String 'Name of the 1st PDF
Dim SCOPE2 As String 'Name of the 2nd PDF
Dim PDFCREATOR As New clsPDFCreator
OLDPRINTER = ActivePrinter
ActivePrinter = "PDFCreator on Ne00:"
SCOPE1 = "1_TdB CLEANING - PARIS"
SCOPE2 = "2_TdB CLEANING - WASTE CENTER"
FILE = ActiveWorkbook.Path
FILE = Replace(FILE, "3_Calcul", "4_Infocentre")
With PDFCREATOR
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = FILE
.cOption("AutosaveFilename") = "combine.pdf"
.cOption("Autosaveformat") = 0
.cStart
.cClearCache
End With
PDFCREATOR.cPrinterStop = True
PDFCREATOR.cPrintFile (FILE & SCOPE1 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200
PDFCREATOR.cPrintFile (FILE & SCOPE2 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200
PDFCREATOR.cCombineAll
PDFCREATOR.cPrinterStop = False
'PDFCREATOR.cClose
ActivePrinter = OLDPRINTER
' Change the default printer
End Sub
Thank you for your help
Configuration: Windows 7 / Firefox 40.0
I'm trying to create a macro to merge two PDF documents but it's not working. Could someone help me? Here’s the macro:
Sub testPrintPDF()
Dim OLDPRINTER As String
Dim FILE As String 'Link to the folder where the PDFs are located
Dim SCOPE1 As String 'Name of the 1st PDF
Dim SCOPE2 As String 'Name of the 2nd PDF
Dim PDFCREATOR As New clsPDFCreator
OLDPRINTER = ActivePrinter
ActivePrinter = "PDFCreator on Ne00:"
SCOPE1 = "1_TdB CLEANING - PARIS"
SCOPE2 = "2_TdB CLEANING - WASTE CENTER"
FILE = ActiveWorkbook.Path
FILE = Replace(FILE, "3_Calcul", "4_Infocentre")
With PDFCREATOR
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = FILE
.cOption("AutosaveFilename") = "combine.pdf"
.cOption("Autosaveformat") = 0
.cStart
.cClearCache
End With
PDFCREATOR.cPrinterStop = True
PDFCREATOR.cPrintFile (FILE & SCOPE1 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200
PDFCREATOR.cPrintFile (FILE & SCOPE2 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200
PDFCREATOR.cCombineAll
PDFCREATOR.cPrinterStop = False
'PDFCREATOR.cClose
ActivePrinter = OLDPRINTER
' Change the default printer
End Sub
Thank you for your help
Configuration: Windows 7 / Firefox 40.0
1 answer
Hello Clemy,
the Excel forum would probably have been more suitable since it concerns an Excel macro, the PDF being just the result.
But check the following link which might give you another lead:
https://www.excel-downloads.com/threads/fusionner-plusieurs-pdf-par-une-macro.173886/
--
C-Claire
the Excel forum would probably have been more suitable since it concerns an Excel macro, the PDF being just the result.
But check the following link which might give you another lead:
https://www.excel-downloads.com/threads/fusionner-plusieurs-pdf-par-une-macro.173886/
--
C-Claire