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
| Dim origPdfDoc As Acrobat.CAcroPDDoc
Dim newPdfDoc As Acrobat.CAcroPDDoc
Dim path As String
Dim path2 As String
Dim path3 As String
Dim varNewTotalPages As Long
path = "d:\temp\a.pdf" ' fichier 1
path2 = "d:\temp\b.pdf" ' fichier 2
path23 = "d:\temp\VOILI.pdf" ' résultat de la fusion
Set origPdfDoc = CreateObject("AcroExch.PDDoc")
Set newPdfDoc = CreateObject("AcroExch.PDDoc")
If origPdfDoc.Open(path) Then
If newPdfDoc.Open(path2) Then
'Get total # of pages too insert
varNewTotalPages = newPdfDoc.GetNumPages
'Insert pages into original pdf
origPdfDoc.InsertPages True, newPdfDoc, 0, varNewTotalPages, False
'Save doc
'origPdfDoc.Save PDSaveIncremental, path 'path doesn't matter, will save to original doc
origPdfDoc.Save PDSaveCopy, path23
Else
MsgBox "Failed to open doc " & path2
End If
'Close docs
origPdfDoc.Close
newPdfDoc.Close
MsgBox "Pages added to " & path3
Else
MsgBox "Failed to add pages to " & path3
End If
Set origPdfDoc = Nothing
Set newPdfDoc = Nothing
End Sub |