excel VBA to read fields from an adobe pdf form

Posted on 2011-05-04
Last Modified: 2012-05-11

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.


Question by:Simon Ball
    LVL 15

    Author Comment

    by:Simon Ball
    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
    LVL 12

    Expert Comment

    Is it not available in your > Tools > References > Acrobat ?

    LVL 12

    Expert Comment

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

    LVL 15

    Accepted Solution

    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.
    LVL 50

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
    PaperPort is a popular document imaging/management product from Nuance Communications ( It is in widespread use by both individuals ( and businesses (http:/…
    This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now