pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi, 'm getting error in the U line.
what 'm trying to achieve here is to combine 2 pdf files into 1.
I have referenced to adobe acrobat 10.x type lib...
please help.
thanks.
Code:
Sub test5()[/FONT][FONT=courier new]'adobe Acrobat 10# type lib[/FONT]
[FONT=courier new]On Error GoTo errhnfler[/FONT]
[FONT=courier new]Dim AcroApp As Acrobat.CAcroApp[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Dim Part1Document As Acrobat.CAcroPDDoc[/FONT]
[FONT=courier new] Dim Part2Document As Acrobat.CAcroPDDoc[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Dim numPages As Integer[/FONT]
[FONT=courier new] [/FONT]
[U][FONT=courier new] Set AcroApp = CreateObject("AcroExch.App")[/FONT][/U]
[FONT=courier new] [/FONT]
[FONT=courier new] Set Part1Document = CreateObject("AcroExch.PDDoc")[/FONT]
[FONT=courier new] Set Part2Document = CreateObject("AcroExch.PDDoc")[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Part1Document.Open ("C:\rpt1CasesByWHContact.pdf")[/FONT]
[FONT=courier new] Part2Document.Open ("C:\rpt2CasesByClientContact.pdf")[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] ' Insert the pages of Part2 after the end of Part1[/FONT]
[FONT=courier new] numPages = Part1Document.GetNumPages()[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] If Part1Document.InsertPages(numPages - 1, Part2Document, 0, Part2Document.GetNumPages(), True) = False Then[/FONT]
[FONT=courier new] MsgBox "Cannot insert pages"[/FONT]
[FONT=courier new] End If[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] If Part1Document.Save(PDSaveFull, "C:\MergedFile.pdf") = False Then[/FONT]
[FONT=courier new] MsgBox "Cannot save the modified document"[/FONT]
[FONT=courier new] End If[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] Part1Document.Close[/FONT]
[FONT=courier new] Part2Document.Close[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] AcroApp.Exit[/FONT]
[FONT=courier new] Set AcroApp = Nothing[/FONT]
[FONT=courier new] Set Part1Document = Nothing[/FONT]
[FONT=courier new] Set Part2Document = Nothing[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] MsgBox "Done"[/FONT]
[FONT=courier new] [/FONT]
[FONT=courier new] End[/FONT]
[FONT=courier new]errhnfler:[/FONT]
[FONT=courier new] Debug.Print Err.Description & " " & Err.Number[/FONT]
[FONT=courier new]End Sub[/FONT]
[FONT=courier new]
[/FONT]
[FONT=courier new]