Search code examples
vbapdfreferenceacrobatlate-binding

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


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)

Solution

  • @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")