bonjour,

je souhaite fusionner 2 PDF sous VBA
dans mon fichier excel, j'ai des onglets qui me permettent de créer un PDF, je souhaite rajouter à ce PDF un autre qui provient de SAS.
pour cela j'ai utilisé ce code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Option Private Module              ' les variables ne sont accessibles qu'au sein de ce projet
 
Public sNomFichierPDF As String
 
Sub PDF()
 
Application.ScreenUpdating = False
W_NOM_CLASSEUR = ActiveWorkbook.Name
Call print_pdf("PDF", 3)
Application.ScreenUpdating = True
 
End Sub
 
 
Sub print_pdf(W_Pdf As String, W_nb As Integer)
 
Dim JobPDF As Object
Dim Ar() As String, Cpt As Long, I As Long
 
sNomFichierPDF = ThisWorkbook.Path & "\" & "test.pdf"
 
Cpt = 0
For I = 1 To ThisWorkbook.Sheets.Count
    If Left$(ThisWorkbook.Sheets(I).Name, W_nb) = W_Pdf Then
        ReDim Preserve Ar(Cpt)
        Ar(Cpt) = Sheets(I).Name
        Cpt = Cpt + 1
    End If
Next I
 
If Cpt = 0 Then Exit Sub
 
Application.ScreenUpdating = False
Sheets(Ar).Select
 
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=sNomFichierPDF _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True
 
Application.ScreenUpdating = True
 
End Sub
cette partie fonctionne très bien.
c'est lorsque je veux rajouter mon autre PDF que ça se complique...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Sub Fusion_PDFs()
Dim oPDDoc1 As Object
Dim oPDDoc2 As Object
Dim Num As Long
 
    Set oPDDoc1 = CreateObject("AcroExch.PDDoc")
    Set oPDDoc2 = CreateObject("AcroExch.PDDoc")
 
    oPDDoc1.Open (ThisWorkbook.Path & "\" & "test.pdf")
    oPDDoc2.Open (ThisWorkbook.Path & "\" & "test SAS.pdf")
 
    oPDDoc1.InsertPages 0, oPDDoc2, 0, 1, 0
 
    oPDDoc1.Save 1, ThisWorkbook.Path & "\" & "Fusion.pdf"
 
    oPDDoc2.Close
    oPDDoc1.Close
 
    Set oPDDoc2 = Nothing
    Set oPDDoc1 = Nothing
End Sub
j'ai l'erreur 429 : un composant ActiveX ne peut pas créer d'objet
merci d'avance pour votre aide