• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

VBA Script with Adobe reference not working after updates

New Here ,
Nov 23, 2021 Nov 23, 2021

Copy link to clipboard

Copied

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 

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Aug 02, 2022 Aug 02, 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)"

Votes

Translate

Translate
New Here ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

Hallo Mark,

 

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

 

Thanks for your help,

 

Sven

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

[Question moved to the Acrobat SDK forum]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 02, 2022 Aug 02, 2022

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 23, 2022 Aug 23, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines