thread705-1272718
I would like to revisit the closed thread, above. It works great, but I would like to adjust it to loop through all PDF files in a specific directory, and merge all files found (perhaps merge to "Source1.pdf" in the example below).
Can anyone please help guide me? Original code below:
Barry
GIS Specialist
I would like to revisit the closed thread, above. It works great, but I would like to adjust it to loop through all PDF files in a specific directory, and merge all files found (perhaps merge to "Source1.pdf" in the example below).
Can anyone please help guide me? Original code below:
Code:
Sub TestCombinePDF()
'Relies on the Adobe Acrobat 6.0 Type Library
Dim objCAcroPDDocDestination As Acrobat.CAcroPDDoc
Dim objCAcroPDDocSource As Acrobat.CAcroPDDoc
'Initialize the objects
Set objCAcroPDDocDestination = CreateObject("AcroExch.PDDoc")
Set objCAcroPDDocSource = CreateObject("AcroExch.PDDoc")
'Open Destination, all other documents will be added to this and saved with
'a new filename
objCAcroPDDocDestination.Open ("C:\Source1.pdf")
'Do your loop here to open subsequent documents that you want to add
'Do
'Open the source document that will be added to the destination
objCAcroPDDocSource.Open ("C:\Source2.pdf")
If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
'-1 Success
Else
'0 problem
End If
objCAcroPDDocSource.Close
'loop
objCAcroPDDocDestination.Save 1, "C:\Destination.pdf"
objCAcroPDDocDestination.Close
Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing
End Sub
Barry
GIS Specialist