Link to home
Start Free TrialLog in
Avatar of Craig Johnson
Craig JohnsonFlag for United States of America

asked on

Merge PDF Question

Thoughts as to why this is giving an error "Run-time error '438' Object doesn't support this property or method"  The debugger says the error is on "AcroExch.App").


Thx

CWJ

---------------------
Sub Merge_PDF()

        Dim AcroExchApp As Acrobat.CAcroApp
        Dim AcroExchPDDoc As Acrobat.CAcroPDDoc
        Dim AcroExchInsertPDDoc As Acrobat.CAcroPDDoc
        Dim strFileName As String, strPath As String
        Dim iNumberOfPagesToInsert As Integer
        Dim iLastPage As Integer

        Set AcroExchApp = CreateObject("AcroExch.App")
        Set AcroExchPDDoc = CreateObject("AcroExch.PDDoc")

        AcroExchApp = CreateObject("AcroExch.App")
        AcroExchPPDoc = CreateObject("AcroExch.PDDoc")
       
        AcroExchApp.Show
       
        strFileName = "C:\1.pdf"
        AcroExchPDDoc.Open (strFileName)

        iLastPage = AcroExchPDDoc.GetNumPages() - 1
       
        AcroExchInsertPDDoc = CreateObject("AcroExch.PDDoc")
        AcroExchInsertPDDoc.Open ("C:\2.pdf")
        iNumberOfPagesToInsert = AcroExchInsertPDDoc.GetNumPages

        AcroExchPDDoc.InsertPages iLastPage - 1, AcroExchInsertPDDoc, 0, iNumberOfPagesToInsert, True
       
        AcroExchInsertPDDoc.Close

        AcroExchPDDoc.Save PDDocRequiresFullSave, "C:\merged.pdf"

        AcroExchPDDoc.Close
        AcroExchApp.Exit
   
        AcroExchInsertPDDoc = Nothing
        AcroExchPDDoc = Nothing
        AcroExchApp = Nothing


End Sub
---------------------

Avatar of Craig Johnson
Craig Johnson
Flag of United States of America image

ASKER

Follow-up....

I will likely be merging 10-20 PDF's with this code.  Any streamlining thoughts would be appreciated...

CWJ
WHich version of Acrobat are you using? I assume you know that this program requires the full version of Acrobat to be installed.
Version 7.0...Yes full version

CWJ
ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Pro