(VBA) Late Binding (avaoid reference) of Acrobat Type Library

这一生的挚爱 提交于 2019-12-11 17:44:18

问题


Is it possible to avoid the reference to the Adobe Acrobat Type Library somehow? I cannot figure it out how...I receive an ActiveX error message.

I only paste an extract of my code as the rest is not that important. Here is the code with early binding (set up reference):

Dim Fol_Path As String
Dim Each_Page As Boolean

Dim AC_PD As Acrobat.AcroPDDoc
Dim AC_Hi As Acrobat.AcroHiliteList
Dim AC_PG As Acrobat.AcroPDPage
Dim AC_PGTxt As Acrobat.AcroPDTextSelect

Dim OS_FSO As Object
Dim OS_TxtFile As Object

Set OS_FSO = CreateObject("Scripting.filesystemobject")

Dim Ct_Page As Long
Dim i As Long, j As Long, k As Long
Dim T_Str As String

Dim Hld_Txt As Variant

Each_Page = True

Set AC_PD = New Acrobat.AcroPDDoc
Set AC_Hi = New Acrobat.AcroHiliteList
AC_Hi.Add 0, 32767

... ... ...

        Set AC_PG = .AcquirePage(i - 1)

        Set AC_PGTxt = AC_PG.CreateWordHilite(AC_Hi)

回答1:


@ACatinLove thanks! It worked! (my code extract as the result). Somewhere I read that one should put "Const AcroExch As Long = 0" after Dim, why is so?

Dim AC_PD As Object
Dim AC_Hi As Object
Dim AC_PG As Object
Dim AC_PGTxt As Object

'Const AcroExch As Long = 0

Dim OS_FSO As Object
Dim OS_TxtFile As Object

Set OS_FSO = CreateObject("Scripting.filesystemobject")

Dim Ct_Page As Long
Dim i As Long, j As Long, k As Long
Dim T_Str As String

Dim Hld_Txt As Variant

Each_Page = True

'Set AC_PD = New Acrobat.AcroPDDoc
'Set AC_Hi = New Acrobat.AcroHiliteList

Set AC_PD = CreateObject("AcroExch.PDDoc")
Set AC_Hi = CreateObject("AcroExch.HiliteList")


来源:https://stackoverflow.com/questions/48028987/vba-late-binding-avaoid-reference-of-acrobat-type-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!