VBA Excel - Fusionner deux pdf avec PDFCreator

Fermé
Clemy - 21 août 2015 à 11:41
C-Claire Messages postés 4014 Date d'inscription samedi 8 novembre 2014 Statut Membre Dernière intervention 3 octobre 2016 - 22 août 2015 à 13:18
Bonjour,

J'essaie de faire une macro pour fusionner deux documents pdf mais elle ne marche pas. Quelqu'un pourrait-il m'aider ? Voici la macro

Sub testPrintPDF()

Dim OLDPRINTER As String
Dim FICHIER As String 'Lien vers le dossier où se trouve les pdf
Dim PERIMETRE1 As String 'Nom du 1er pdf
Dim PERIMETRE2 As String 'Nom du 2nd pdf
Dim PDFCREATOR As New clsPDFCreator

OLDPRINTER = ActivePrinter
ActivePrinter = "PDFCreator sur Ne00:"

PERIMETRE1 = "1_TdB PROPRETE - PARIS"
PERIMETRE2 = "2_TdB PROPRETE - DÉCHETTERIE"
FICHIER = ActiveWorkbook.Path
FICHIER = Replace(FICHIER, "3_Calcul", "4_Infocentre")

With PDFCREATOR
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = FICHIER
.cOption("AutosaveFilename") = "combine.pdf"
.cOption("Autosaveformat") = 0
.cStart
.cClearCache
End With

PDFCREATOR.cPrinterStop = True
PDFCREATOR.cPrintFile (FICHIER & PERIMETRE1 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200
PDFCREATOR.cPrintFile (FICHIER & PERIMETRE2 & ".pdf") 'pdf-reader pops up and freezes until it is closed
Sleep 200

PDFCREATOR.cCombineAll

PDFCREATOR.cPrinterStop = False

'PDFCREATOR.cClose
ActivePrinter = OLDPRINTER
' Change l'imprimante par défaut

End Sub

Merci de votre aide

1 réponse

C-Claire Messages postés 4014 Date d'inscription samedi 8 novembre 2014 Statut Membre Dernière intervention 3 octobre 2016 2 211
22 août 2015 à 13:18
Bonjour Clemy,

le forum Excel aurait sans doute été plus adapté puisqu'il s'agit d'une macro Excel, le PDF n'étant que le résultat.
Mais regarde le lien suivant qui te donnera peut-être une autre piste :
https://www.excel-downloads.com/threads/fusionner-plusieurs-pdf-par-une-macro.173886/
0