• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

VBA Code error with Adobe Acrobat 10 Type Library

Community Beginner ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

63.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

I doubt that this ever worked with Reader 9. You are using an interface

that is only available when you have Adobe Acrobat installed. There are

some features in the IAC (Interapplication Communication) API, but it's

very limited. The documentation will tell you what's available what what's

not.

Karl Heinz Kremer

PDF Acrobatics Without a Net

khk@khk.net

http://www.khkonsulting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Is Adobe Acrobat installed on the system? Your code will not work with Adobe Reader.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Sorry....I meant to say Adobe Acrobat 9.

And 'Yes' this code works in 9 but not in 10.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

And you have Adobe Acrobat X ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Yes, Adobe Acrobat X Standard it what comes up under the Windows XP Start menu.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Check whether you maybe also have some copy of Adobe Reader installed, could be confusing things.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Reader and Acrobat can peacefully coexist on the same system. I can even

have Reader and Acrobat run at the same time, and the VBA code still

"knows" what application to talk to. So that's very likely not the problem

either. What can cause problems is to have multiple versions of Acrobat

installed on the same system.

Karl Heinz Kremer

PDF Acrobatics Without a Net

khk@khk.net

http://www.khkonsulting.com

On Tue, Jan 29, 2013 at 11:49 AM, Test Screen Name <forums_noreply@adobe.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Adobe Acrobat Acrobat X and Adobe Acrobat Distiller X are the only Adobe apps currently installed.

On PCs with Adobe Acrobat 9 and Distiller 9 installed I am not having any problems.  Only with the PCs that have 10 installed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 29, 2013 Jan 29, 2013

Copy link to clipboard

Copied

Ok, that changes things Have you tried a new project? Do you run into

the same error when you start a new MS Word VBA project from scratch? What

you are doing is pretty basic, and it should definitely work. Because you

get past the first line that uses the OLE API, I assume that you have a

valid reference to Acrobat.tlb. From that point on, things should just

work.

I just pasted your code into a button handler of a new word document, and

the line you are having a problem with does not cause any problems. I run

into problems further down, when the code tries to use

lstSelected.ListCount

So, whatever your problem is is not with Acrobat X, there must be something

wrong with your code project.

As I said, I would start to debug this with a brand new project and see if

you run into the same problem, if not, then see if you can copy and paste

code from the corrupt project to the new project. You will either end up

with a working project, or you will see what other parts are necessary to

make the code fail.

Karl Heinz Kremer

PDF Acrobatics Without a Net

khk@khk.net

http://www.khkonsulting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 30, 2013 Jan 30, 2013

Copy link to clipboard

Copied

OK.  So I did as you suggested.

On the PC with Adobe Acrobat X Standard I created a brand new Word document and built all my code/forms up from scratch.  But unfortunately, I am running into the same issue.  A "Type Mismatch" error at the same line of code.

As you mentioned, the line above compiles fine, but the next one crashes.  Perhaps a bad Acrobat.tlb file??

I'm running out of ideas.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2013 Jan 30, 2013

Copy link to clipboard

Copied

What if you start with a really simple VBA example? Take a look at this:

Private Sub CommandButton1_Click()

Dim AcroApp As Acrobat.CAcroApp

Dim theDocument As Acrobat.CAcroPDDoc

Dim bm As Acrobat.AcroPDBookmark

Dim thePath As String

thePath = "c:\temp\test.pdf"

Set AcroApp = CreateObject("AcroExch.App")

Set theDocument = CreateObject("AcroExch.PDDoc")

theDocument.Open (thePath)

MsgBox "Number of pages: " & theDocument.GetNumPages

theDocument.Close

AcroApp.Exit

Set AcroApp = Nothing

Set theDocument = Nothing

Set bm = Nothing

MsgBox "Done"

End Sub

If this still does not work, I would reinstall Acrobat to make sure that

the TLB is not corrupt.

Karl Heinz Kremer

PDF Acrobatics Without a Net

khk@khk.net

http://www.khkonsulting.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 30, 2013 Jan 30, 2013

Copy link to clipboard

Copied

Hi Karl,

Thanks for the code, but still no luck.  Same error as before, at the same line:  Set theDocument = CreateObject("AcroExch.PDDoc")

Perhaps my best option now is to get Adobe re-installed.  Strange that the AcroExch.App doesn't cause a problem though.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 08, 2013 Nov 08, 2013

Copy link to clipboard

Copied

Ran across this looking for something else.

Did you ever find an answer? If not, I may have a suggestion, odd as it may seem.

I am doing virtually the same thing on a system running Acrobat X Pro. One difference in your code and mine is that I do not explicitly type (if that's the right way to say it) my application variable as you do in the line "Dim acrobatApp As Acrobat.acroApp", nor do I use a related "set" statement for that particular variable. Apart from that, the rest of my code almost mirrors the flow of yours.

I realize not defining one's variables is not a best practice when writing code, but I also know my code works like a charm in this state. And I'm not even sure I did that on purpose as it was some time ago that I put it together, thanks to Karl's Ramblings on the subject. Go Karl!

Might be worth  a try to comment out those two lines and see if your errors clear up. Finding out "why" will be interesting, but getting your code to work first will be even more interesting.

Just thought I'd put it out there.

Thanks.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 08, 2013 Nov 08, 2013

Copy link to clipboard

Copied

Basically after I downgraded to v9 everything worked again, so I haven't really looked into much after that.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 04, 2013 Feb 04, 2013

Copy link to clipboard

Copied

I had the same error (429 ActiveX component can't create object) at the same line when trying to create the same object using 10 but not in 9. I then sat down at a computer with Adobe Pro Extended and the code works just fine.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 19, 2017 Aug 19, 2017

Copy link to clipboard

Copied

I am having the same problem with Windows 10, VBA for Excel and Adobe InDesign CS6 and Illustrator CS6 Type library. Same errors Type mismatch trying to instantiate the application. and then errors setting the document as a child of the app. I lost a $4000 job because of this.

.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 19, 2017 Aug 19, 2017

Copy link to clipboard

Copied

LATEST

You need Adobe Acrobat to combine PDF files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines