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

Read Acrobat document fields into excel file

New Here ,
Nov 21, 2020 Nov 21, 2020

Copy link to clipboard

Copied

Hi,

 

I'm having trouble exporting field names and values to an excel file using vba code. I'm pretty sure the code worked until a few weeks ago.

 

I'm working with Acrobat Pro DC version 2020.012.20041 and excel 2016 (16.0.5071.1000) 32 bits

I have references to Adobe Acrobat 10.0 Type library & AFormAut 1.0 Type Library

I'm sure the acrobat document (file attached to this post) has fields as the program line

Debug.print Fields.count gives 108 as result

 

The codes gives an error on the line.

For Each Field In Fields

 

It seems it does not recognize Field as an element. I cannot find anything on the internet that indicates something changed. Any help would be very much appreciated.

 

Here is my entire code

Sub AcrobatLezen()


Dim row_number As Long
Dim AcroApp As Acrobat.CAcroApp
Dim AcroDoc As Acrobat.CAcroAVDoc
Dim Field As AFORMAUTLib.Field
Dim Fields As AFORMAUTLib.Fields
Dim AcroForm As AFORMAUTLib.AFormApp
Dim MyFile As String
Dim ws As Worksheet
Dim x As Integer


row_number = 1

Set AcroApp = CreateObject("AcroExch.App")
Set AcroDoc = CreateObject("AcroExch.AVDoc")

Set ws = ActiveSheet
row_number = 2
MyFile = Application.GetOpenFilename("PDF Files,*.pdf")


If AcroDoc.Open(MyFile, "") Then
AcroApp.Show
Set AcroForm = CreateObject("AFormAut.app")
Set Fields = AcroForm.Fields
Debug.Print Fields.Count

'On the next lign code stops - Cannot find element
For Each Field In Fields
row_number = row_number + 1
ws.Range("CH" & row_number) = Field.Name
ws.Range("CI" & row_number) = Field.Value
Next Field
Else
MsgBox "Fout"

End If

AcroApp.CloseAllDocs
AcroApp.Exit
AcroApp.Hide
Set AcroApp = Nothing
Set AcroDoc = Nothing
Set Field = Nothing
Set Fields = Nothing

End Sub

 

TOPICS
Acrobat SDK and JavaScript

Views

369

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
no replies

Have something to add?

Join the conversation