Skip to main content
Participant
March 3, 2020
Answered

Fill PDF from from Access VBA

  • March 3, 2020
  • 1 reply
  • 2869 views

Hi All

I have a PDF form that is I am trying to automate and fill in from an Access Database. I have been working on this for a couple of weeks.  I was able to find a solution that will work from Excel VBA:

The problem that I am having is that part of the solution I need uses the word "Form" which is a restricted word in MSAccess.  Does anyone know how I would be able to properly automate this from MSAccess VBA - and not Excel VBA

 The issue is the line of code that Starts with jso.xfa.form...... - as I mentioned the word Form is restricted - so while I understand that this is a Livecycle designed form (not by me) - since the fields I am trying to update a Check kboxes - the jso.getfield.... code does not work.

 Any assistance would be greatly appreciated

 

Thanks

 Jeff

Here is my Code:

Sub Test()

Dim FileNm, gApp, avDoc, pdDoc, jso
Dim FileNm2


FileNm = "C:\HSAR_DB\WAR\HOIR.pdf"
FileNm2 = "C:\HSAR_DB\WAR\HOIR3.pdf"

 

Set gApp = CreateObject("AcroExch.app")

Set avDoc = CreateObject("AcroExch.AVDoc")

If avDoc.Open(FileNm, "") Then

Set pdDoc = avDoc.GetPDDoc()

Set jso = pdDoc.GetJSObject

 

'THIS LINE WORKS IN BOTH EXCEL AND ACCESS

jso.getfield("LAB1070_E[0].Page1[0].txtF-3_Time[0]").Value = "1130"

 

'THIS LINE WORKS IN EXCEL BUT NOT ACCESS

jso.xfa.form.LAB1070_E.Page1.DSBInj.rawValue = "1"

pdDoc.Save 1, FileNm2

 

avDoc.Close (True)

Set gApp = Nothing

Set avDoc = Nothing

Set pdDoc = Nothing

Set jso = Nothing

End Sub()

 

This topic has been closed for replies.
Correct answer jefff34942432

I just figured it out:

 

jso.xfa.resolvenode("form.LAB1070_E.Page1.DSBInj").rawvalue = "1"

 

Worked in both Excel and Access - and might be useful for anyone else trying to automate like this

 

Jeff

1 reply

jefff34942432AuthorCorrect answer
Participant
March 3, 2020

I just figured it out:

 

jso.xfa.resolvenode("form.LAB1070_E.Page1.DSBInj").rawvalue = "1"

 

Worked in both Excel and Access - and might be useful for anyone else trying to automate like this

 

Jeff

Participant
November 30, 2023

Thank you Jeff. This code is definitely working.


As I'm handling XFA files which have dynamic form controls like 'Add' or 'delete' buttons, could you help me in the below:

 

(1) Add more rows dynamically in XFA form to enter the data e.g., sales orders. These sales orders can be added by clicking on 'Add' button on XFA, however, we would like to handle this programmatically using VBA

 

(2) How to click on a button/radio button/select a value from listbox given in XFA FORM using vba.

 

I would be very grateful.