Skip to main content
Participant
November 24, 2021
Answered

VBA Script with Adobe reference not working after updates

  • November 24, 2021
  • 4 replies
  • 2516 views

Hi All,

A vba script that I've used for years is suddenly stuck on an error I can't resolve. The code essentially points to a PDF and uses that PDF's bookmarks to create a Table of Contents in a word document. 

 

I upgraded to Windows 10 from 7 and Adobe Pro DC from Adobe Pro 10 since the last time I ran it so I don't know which software is causing a problem. Here is the code :

 

Sub loop_thru_members()

Application.ScreenUpdating = False

Dim membCode(), a As Integer

membCode = Array("BH")

For a = 0 To UBound(membCode)

Call BFormulaire_Click(membCode(a))

Next

Application.ScreenUpdating = True
End Sub


Private Sub BFormulaire_Click(fff)
Dim retour As Boolean
Dim PInt_Retour_X_pixel As Integer
Dim PInt_Retour_Y_Pixel As Integer
Dim AcroExchApp As Object, AcroPDFDoc As Object, AcrobatViewPage As Object, _
AcrobatPage As Object, AcrobatTaille As Object, acroform As Object, Champs As Object, _
field As Object, oneg As String, sJS3b As String, sJS4 As String, tr As String

Set AcroExchApp = CreateObject("AcroExch.App")
AcroExchApp.Show
Set AcroPDFDoc = CreateObject("AcroExch.AVDoc")
retour = AcroPDFDoc.Open("a:\" & fff & "_test.pdf", "Title of window")

If Not retour Then
MsgBox "Pb oopen"
Exit Sub
End If

Set AcrobatViewPage = AcroPDFDoc.GetAVPageView
Set AcrobatPage = AcrobatViewPage.GetPage
Set AcrobatTaille = AcrobatPage.GetSize
PInt_Retour_X_pixel = AcrobatTaille.x
PInt_Retour_Y_Pixel = AcrobatTaille.y
Set AcrobatTaille = Nothing

Set acroform = CreateObject("AFormAut.App")
Set Champs = acroform.Fields
Set field = Champs.Add("Plan", "button", 0, 10, PInt_Retour_Y_Pixel - 10, 70, PInt_Retour_Y_Pixel - 50)
field.Value = "consultation du plan"
field.ButtonLayout = 1
field.Highlight = "none"
field.PrintFlag = False
oneg = "MouseUp"

End Sub

 

The program errors on the line : "Set Champs = acroform.Fields" with the error: 

Run time error :2147319765 (8002802b) 

Automation error Element Not Found.

I activated the adobe references in Word: AFormAut 1.0 Type Library and Adobe Acrobat 10.0 Type Library. Didnt change anything. Anyone have any thoughts? Attached is a sample pdf just for testing. 

Thanks for your help,

Mark 

This topic has been closed for replies.
Correct answer DalvinCentury

I just had this same issue. I fixed it by going into Adobe Acrobat and selecting

Edit > Preferences > Security (Enhanced)

And then deselecting the box at the top labelled "Enable Protected Mode as Startup (Preview)"

4 replies

DalvinCenturyCorrect answer
Participant
August 2, 2022

I just had this same issue. I fixed it by going into Adobe Acrobat and selecting

Edit > Preferences > Security (Enhanced)

And then deselecting the box at the top labelled "Enable Protected Mode as Startup (Preview)"

Participant
August 23, 2022

This was my solution as well. Thanks for your help! 

Participating Frequently
April 20, 2022

I also have a similar sitution where scripts stopped working, did you find a solution?

try67
Community Expert
Community Expert
April 1, 2022

[Question moved to the Acrobat SDK forum]

Participant
April 1, 2022

Hallo Mark,

 

I have the same problem - do you have a solution?

 

Thanks for your help,

 

Sven