17 Replies Latest reply on Aug 19, 2017 6:11 AM by Bernd Alheit

    VBA Code error with Adobe Acrobat 10 Type Library

    bbulla1

      Hi,

       

      I have some code I created in Word VBA to combine several separate PDFs into a single PDF.  The code works fine with the Adobe Acrobat 9.0 Type Library and Adobe Reader 9.0 installed.

       

      But, with the Adobe Acrobat 10 Type Library and Adobe Reader 10 installed, the code fails at the marked code below.  Any suggestions??

       

          Dim acrobatApp As Acrobat.acroApp

          Set acrobatApp = CreateObject("AcroExch.App")

       

       

          Dim mainPDF As Acrobat.AcroPDDoc

          Set mainPDF = CreateObject("AcroExch.PDDoc")  ****THIS IS WHERE THE CODE STOPS WITH A "TYPE MISMATCH" ERROR****

         

          Dim nextPage As Acrobat.AcroPDDoc

          Set nextPage = CreateObject("AcroExch.PDDoc")

             

          Dim numPages As Integer

         

          'Loop through all selected VLS, and add each one to the end of the main PDF

          For i = 0 To lstSelected.ListCount - 1

              mainPDF.Open CurDir & "\" & Replace(ThisDocument.Name, ".doc", "") & ".pdf"

              numPages = mainPDF.GetNumPages

              nextPage.Open lstSelected.List(i)

             

              If mainPDF.InsertPages(numPages - 1, nextPage, 0, nextPage.GetNumPages, True) = False Then

                  MsgBox "Cannot insert pages"

              End If

             

              If mainPDF.Save(PDSaveFull, CurDir & "\" & Replace(ThisDocument.Name, ".doc", "") & ".pdf") = False Then

                  MsgBox "Cannot save"

              End If

             

              'MsgBox lstSelected.List(i)

              nextPage.Close

          Next i