• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1679
  • Last Modified:

excel VBA to read fields from an adobe pdf form

Hello.

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.

cheers

Sudo.
0
Simon Ball
Asked:
Simon Ball
  • 2
  • 2
1 Solution
 
Simon BallAuthor Commented:
further info:

i found this article :
http://www.experts-exchange.com/Web_Development/Document_Imaging/Adobe_Acrobat/Q_26489233.html?sfQueryTermInfo=1+10+30+excel+form+pdf+vba

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
    theForm.Close
     
    AcroApp.Exit
    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
0
 
danishaniCommented:
Is it not available in your > Tools > References > Acrobat ?

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

HTH,
Daniel
0
 
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.
0
 
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.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now