VBA:Acrobat运行时错误429; ActiveX组件无法创建对象 [英] VBA: Acrobat Run time error 429; ActiveX component can't create object

查看:309
本文介绍了VBA:Acrobat运行时错误429; ActiveX组件无法创建对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码从Excel VBA中的PDF文件中读取内容:

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

但是,我在

Set AcroApp = CreateObject("AcroExch.App")

怎么了?我有Adobe Reader X,我检查过的引用是:

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

Acrobat Access 3.0类型库 AcroBrokerLib AcroIEHelper 1.0类型库 AcroIEHelperShim 1.0类型库 Adobe Acrobat浏览器控件类型库1.0 Adobe Acrobat 10.0类型库 Adobe Reader文件预览类型库

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

推荐答案

从Google搜索查询的第一个结果开始:

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

createobject acroexch.app错误429

createobject acroexch.app error 429

您无法使用Adobe Reader进行此操作,需要Adobe Acrobat:

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

此OLE接口可用于Adobe Acrobat,而不适用于Adobe Reader.

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

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

这篇关于VBA:Acrobat运行时错误429; ActiveX组件无法创建对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆