Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Fill PDF from from Access VBA

New Here ,
Mar 03, 2020 Mar 03, 2020

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()

 

TOPICS
PDF forms
2.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
New Here ,
Mar 03, 2020 Mar 03, 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

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 03, 2020 Mar 03, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 29, 2023 Nov 29, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines