VBA: Acrobat Run time error 429; ActiveX component can't create object

21,407

From the very first result in Google for the search query:

createobject acroexch.app error 429

You cannot do this with Adobe Reader, you need Adobe Acrobat:

This OLE interface is available with Adobe Acrobat, not Adobe Reader.

https://forums.adobe.com/thread/657262

Share:
21,407
Mariska
Author by

Mariska

Updated on June 28, 2021

Comments

  • Mariska
    Mariska almost 3 years

    I have the following codes to read in contents from a PDF file in Excel VBA:

    'Note: A Reference to the Adobe Library must be set in Tools|References!
    Dim AcroApp As CAcroApp, AcroAVDoc As CAcroAVDoc, AcroPDDoc As CAcroPDDoc
    Dim AcroHiliteList As CAcroHiliteList, AcroTextSelect As CAcroPDTextSelect
    Dim PageNumber, PageContent, Content, i, j
    Set AcroApp = CreateObject("AcroExch.App")
    Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
    If AcroAVDoc.Open(strFileName, vbNull) <> True Then Exit Function
    ' The following While-Wend loop shouldn't be necessary but timing issues may occur.
    While AcroAVDoc Is Nothing
      Set AcroAVDoc = AcroApp.GetActiveDoc
    Wend
    Set AcroPDDoc = AcroAVDoc.GetPDDoc
    For i = 0 To AcroPDDoc.GetNumPages - 1
      Set PageNumber = AcroPDDoc.AcquirePage(i)
      Set PageContent = CreateObject("AcroExch.HiliteList")
      If PageContent.Add(0, 9000) <> True Then Exit Function
      Set AcroTextSelect = PageNumber.CreatePageHilite(PageContent)
      ' The next line is needed to avoid errors with protected PDFs that can't be read
      On Error Resume Next
      For j = 0 To AcroTextSelect.GetNumText - 1
        Content = Content & AcroTextSelect.GetText(j)
      Next j
    Next i
    ReadAcrobatDocument = Content
    AcroAVDoc.Close True
    AcroApp.Exit
    Set AcroAVDoc = Nothing: Set AcroApp = Nothing
    
    End Function
    
    Sub demo()
    
        Dim str As String
        str = ReadAcrobatDocument("C:\Desktop\asdf.pdf")
    
    End Sub
    

    However, I am getting the runtime 429 error at

    Set AcroApp = CreateObject("AcroExch.App")
    

    What is wrong? I have Adobe Reader X and the references I've checked are:

    Acrobat Access 3.0 Type Library AcroBrokerLib AcroIEHelper 1.0 Type Library AcroIEHelperShim 1.0 Type Library Adobe Acrobat Browser Control Type Library 1.0 Adobe Acrobat 10.0 Type Library Adobe Reader File Preview Type Library

    • rory.ap
      rory.ap about 9 years
      Why are you using CreateObject("AcroExch.App") and not the constructor? If you're including a reference to that library, you don't need to use CreateObject("AcroExch.App").
    • Mariska
      Mariska about 9 years
      What should the constructor be?
    • rory.ap
      rory.ap about 9 years
      I don't know. You're the one who as access to the Adobe API. Does it have any documentation? I would assume it's just a parameter-less constructor.
    • Mariska
      Mariska about 9 years
      I tried "Set AcroApp = New AcroApp" and the same error occurred..
    • rory.ap
      rory.ap about 9 years
      That error usually occurs when the class doesn't exist. Are you sure you have all the appropriate DLLs registered?
  • aks
    aks almost 3 years
    Thank you for your answer! I had only Adobe Reader, not Acrobat.