Link to home
Start Free TrialLog in
Avatar of whymepa
whymepaFlag for United States of America

asked on

Use VB6 to Populate PDF Form Fields

I found the following sample code which should allow me to populate a PDF form field from VB6.  

When I run this code I get "Error 424: Object Required" on the "Set objField = jso.getField("TextField1")" line of code.  The field I'm trying to populate is TextField1.  I confirmed that field is the proper name on my PDF form.  I added a reference to Adobe Acrobat 7.0 Type Library.  I'm using Adobe Designer v7 to create my form.  I've seen other questions similar to this but none have really helped.  Any advice on how to correct this issue or sample code someone can share is greatly appreciated.  
Dim gApp As Acrobat.CAcroApp
    Dim gPDDoc As Acrobat.CAcroPDDoc
    Dim jso As Object
    Dim objField As Object
 
    Set gApp = CreateObject("AcroExch.App")
    Set gPDDoc = CreateObject("AcroExch.PDDoc")
 
'populate Data
    If gPDDoc.Open("Path") Then
        Set jso = gPDDoc.GetJSObject
        Set objField = jso.getField("TextField1")
        Set objField.Value = "value"
    End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Karl Heinz Kremer
Karl Heinz Kremer
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of whymepa

ASKER

Thanka for the quick response.  My knowledge of Adobe is very limited.  Based on your comment I created a new PDF and added a new field called text1.  I added the field by going to Tools -> Advanced Editing -> Text Field Tool.  I adjusted my code accordingly based on the control being named text1.  When I run the code I no longer receive my original message.  Now I get the same error on "Set objField.Value = "value"".  Any idea or samples you can provide me to get around this?  I appreciate the assistance.
Avatar of whymepa

ASKER

Figured it out.  Last line of code should be: objField.Value = "value".

Thanks for the guidance!
Avatar of beechdriver100
beechdriver100

I am in the same place that this user is in-very limited on Adobe forms. I've done this on WORD forms with success.

Does anybody know the code for how to then 'view' the form?