excel VBA to read fields from an adobe pdf form


My friend has people sending him completed pdf forms.  He has been typing in the form contents into a spreadsheet.  I said it could probably be done with VBA... should have looked around first...

Found lots of stuff about using the Acrobat writer softwares DLL as a reference in VBA in order to write data into a form from excel, but i don;t have writer software, and i'd like to import the fields data.

i can manage vba to browse for pdf file and get filename and path.. and i read that a pdf is only a tar'd xml file...

does anyone know a quick / easy / free (delete as appropriate) method for importing the data from a pdf form into excel.


LVL 15
Simon BallAsked:
Who is Participating?
Simon BallAuthor Commented:
thanks Daniel.
thats what i was expecting, but not what i wanted to hear...:P

I found some ocx controls which let you open pdfs in a vb form, and one of them has a form object collection, i have emailed the author to see if their tool can do it.
Simon BallAuthor Commented:
further info:

i found this article :

which calls this code:

Private Sub CommandButton1_Click()
    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 fiels Text1 and Text2
    text1 = jso.getField("Text1").Value
    text2 = jso.getField("Text2").Value
    MsgBox "Values read from PDF: " & text1 & " " & text2
    Set AcroApp = Nothing
    Set theForm = Nothing
    MsgBox "Done"
End Sub

Open in new window

but when i try and run it i get an error, presumably as i do not have acrobat as a reference..

 Set gApp = CreateObject("AcroExch.App") ' make acrobat session

Runtime Error 429
ActiveX component cannot create object
Is it not available in your > Tools > References > Acrobat ?

Also you need to have the Full version of Acrobat to get this code work, with only the Reader version you cant.

Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
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.

All Courses

From novice to tech pro — start learning today.