Reading data from an Adobe LiveCycle PDF with VBA

I am attempting to read field values from a PDF form created with Adobe LiveCycle using VBA (Microsft Access 2010).
I believe Acrobat Pro must be installed on the system, Reader will not suffice.

I found an article with the following example:
    Dim AcroApp As Acrobat.CAcroApp
    Dim theForm As Acrobat.CAcroPDDoc
    Dim jso As Object
    Dim text1, text2 As String

    Set AcroApp = CreateObject("AcroExch.App")
    Set theForm = CreateObject("AcroExch.PDDoc")
    theForm.Open ("C:\temp\sampleForm.pdf")
    Set jso = theForm.GetJSObject

    ' get the information from the form fields Text1 and Text2
    text1 = jso.getField("Text1").Value
    text2 = jso.getField("Text2").Value

    MsgBox "Values read from PDF: " & text1 & " " & text2

    ' set a text field
    Dim field2 As Object
    Set field2 = jso.getField("Text2")

    field2.Value = 13   ' assign the number 13 to the fields value

    ' get the information from the form fields Text1 and Text2
    text1 = jso.getField("Text1").Value
    text2 = jso.getField("Text2").Value

    MsgBox "Values read from PDF: " & text1 & " " & text2

    theForm.Close

    AcroApp.Exit
    Set AcroApp = Nothing
    Set theForm = Nothing

    MsgBox "Done"

Open in new window

However, providing a field name from my PDF to getField() did not yield an object.

I found another article that indicated that forms created with LiveCycle had to be accessed via the XFA object.
jso.xfa.Form.form1.RMPCR.txtMerchant.rawValue

Open in new window

The above code block is for my PDF, it resulted in a runtime error.
I am not sure if this approach is totally incorrect or if my property chain is just wrong.

hierarchy.PNG
LVL 1
bejhanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bejhanAuthor Commented:
I was able to print the field names with the following code.
    numFields = jso.numFields
    
    For FldNum = 0 To numFields - 1
        Debug.Print jso.GetNthFieldName(FldNum)
        Debug.Print jso.getField(jso.GetNthFieldName(FldNum)).Value
    Next FldNum

Open in new window


This resulted in field names such as the following: form1[0].RPCA[0].#subform[3].Footer[0].txtInitial[0]

Following this naming convention I was able to retrieve my desired field value with the following statement:
jso.getField("form1[0].RMPCR[0].txtMerchant[0]").Value

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.