Skip to main content
New Participant
September 30, 2021
Question

VBA to edit XFA pdf

  • September 30, 2021
  • 1 reply
  • 2337 views

does it support to use VBA to edit XFA pdf?

 

I am able to get the field value with below path:

 

jso.getfield("residualValueForm[0].en[0].SectionA[0].TableGeneralInfo[0].RowIssuer[0].issuer[0]").Value

 

but I am not able to update the field using the same path or resolvenode with either of below:

 

jso.getfield("residualValueForm[0].en[0].SectionA[0].TableGeneralInfo[0].RowIssuer[0].issuer[0]").Value = "1"

 

jso.xfa.resolvenode("residualValueForm[0].en[0].SectionA[0].TableGeneralInfo[0].RowIssuer[0].issuer[0]").rawvalue = "1"

 

jso.xfa.resolvenode("forms.residualValueForm.en.SectionA.TableGeneralInfo.RowIssuer.issuer").rawvalue = "1"

jso.xfa.form.residualValueForm.en.SectionA.TableGeneralInfo.RowIssuer.Issuer.rawValue = "1"

This topic has been closed for replies.

1 reply

Brainiac
September 30, 2021

The problem here is no actually VBA. It is JavaScript. XFA forms have an ENTIRELY DIFFERENT JavaScript implementation, In particular, getField does not exist at all. You need to refer to the XFA JavaScript reference. 

New Participant
September 30, 2021

In this case, is it feasible to fill in XFA form via VBA? "XFA JavaScript reference" is eligible to reference via VBA?

 

If yes, do you know where I can get sample code? Thank very much

New Participant
November 5, 2021

it depend whether your pdf to popular is in general pdf format or XFA.

 

if it is XFA , you need to populate the value by importing xml.

 

otherwise, you can just manipulate the form data direcly in VBA via the pdf object. 

 

Further code sample is available in google. 


Thank you so much for the reply. The form i am working with is in fact dynamic XFA form. Would kindly provide an example of how i would do the XML import. One expert suggested using jso.xfa.resolvenode i.e. doing something like this:  jso.xfa.resolvenode("form.LAB1070_E.Page1.DSBInj").rawvalue = "1"

 

However, i think my problem is that i am not get the right field name as i continue to get run-time error 424 Object required. I found a sample code to display all of the fields and here is what i am seeing:

Field(0) = form1[0].#subform[0].EmployeeID[0], Value = 213
Field(1) = form1[0].#subform[0].RatingOfficialID[0], Value = 15
Field(2) = form1[0].#subform[0].ReviewingOfficialID[0], Value = 23
Field(3) = form1[0].#subform[0].EmployeeName[0], Value = PASTEEL, CHARLIE K.

 

Based on above field names, i am able to read the values from the form using the code:

text1 = jso.getField("form1[0].#subform[0].EmployeeID[0]").Value

Below are the variations of what i have tried to set/update the value that was mentioned in this post...but does not work:

  jso.xfa.resolvenode("form1[0].#subform[0].EmployeeID[0]").rawvalue = "xxxxxxxxxxx"

  jso.xfa.resolvenode("form1.#subform.EmployeeID").rawvalue = "xxxxxxxxxxx"

 

  jso.getField("form1[0].#subform[0].EmployeeID[0]").Value = "xxxxxxxxx"

 

I have to be able to update & save the form for 850 employees using data from Excel sheet.  I would greatly appreciate your help on this. 

Thanks in advance, Charlie.