I have a piece of code that i'm trying to use to combine 8 "PDF" files. I run the code and it will not create the new file. I've been at this for 2 weeks and i'm close but no cigar....
HELP!
Rich1968
Here's the code. I use access 2003 and Acrobat 6.0
Function MergePDF()
'Relies on the Adobe Acrobat 6.0 Type Library
Dim objCAcroPDDocDestination As Acrobat.CAcroPDDoc
Dim objCAcroPDDocSource As Acrobat.CAcroPDDoc
Dim fso As Scripting.FileSystemObject
Dim f As File
Dim fldr As Folder
'Initialize the objects
Set fso = New Scripting.FileSystemObject
Set fldr = fso.GetFolder("C:\Edocs\")
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:\Edocs\CMS Proposal.pdf")
'Do your loop here to open subsequent documents that you want to add
For Each f In fldr.Files
If InStr(f.Name, "*.pdf") Then
'Open the source document that will be added to the destination
objCAcroPDDocSource.Open (f)
If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
MsgBox "Documents Merged!"
End If
Else
MsgBox "You have a problem"
End If
Next f
objCAcroPDDocSource.close
objCAcroPDDocDestination.Save 1, "C:\Edocs\CMS Proposal.pdf"
objCAcroPDDocDestination.close
Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing
End Function
HELP!
Rich1968
Here's the code. I use access 2003 and Acrobat 6.0
Function MergePDF()
'Relies on the Adobe Acrobat 6.0 Type Library
Dim objCAcroPDDocDestination As Acrobat.CAcroPDDoc
Dim objCAcroPDDocSource As Acrobat.CAcroPDDoc
Dim fso As Scripting.FileSystemObject
Dim f As File
Dim fldr As Folder
'Initialize the objects
Set fso = New Scripting.FileSystemObject
Set fldr = fso.GetFolder("C:\Edocs\")
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:\Edocs\CMS Proposal.pdf")
'Do your loop here to open subsequent documents that you want to add
For Each f In fldr.Files
If InStr(f.Name, "*.pdf") Then
'Open the source document that will be added to the destination
objCAcroPDDocSource.Open (f)
If objCAcroPDDocDestination.InsertPages(objCAcroPDDocDestination.GetNumPages - 1, objCAcroPDDocSource, 0, objCAcroPDDocSource.GetNumPages, 0) Then
MsgBox "Documents Merged!"
End If
Else
MsgBox "You have a problem"
End If
Next f
objCAcroPDDocSource.close
objCAcroPDDocDestination.Save 1, "C:\Edocs\CMS Proposal.pdf"
objCAcroPDDocDestination.close
Set objCAcroPDDocSource = Nothing
Set objCAcroPDDocDestination = Nothing
End Function