Skip to main content
Participant
Nov 24, 2021 1:07 AM UTC
Answered

VBA Script with Adobe reference not working after updates

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 is closed to new replies. Start a new post to keep the conversation going.
DalvinCenturyCorrect answer
Participant
Aug 2, 2022 1:22 PM UTC

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

5 replies

DalvinCenturyCorrect answer
Participant
Aug 2, 2022 1:22 PM UTC

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

Translate
Participant
Aug 23, 2022 9:40 PM UTC

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

Translate
Participating Frequently
Apr 20, 2022 10:34 AM UTC

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

Translate
try67
Community Expert
Community Expert
Apr 1, 2022 8:01 PM UTC

[Question moved to the Acrobat SDK forum]

Translate
Participant
Apr 1, 2022 2:48 PM UTC

Hallo Mark,

 

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

 

Thanks for your help,

 

Sven

 

 

Translate