Solved

MS Access VBA to update Adobe form checkbox and radiobuttonlist

Posted on 2013-01-30
10
1,594 Views
Last Modified: 2014-01-22
Hope you can help. I am ok with updating text boxes on an Adobe form via VBA, but not the Radiobutton list. A code sample would be great.

Code segment (text field updates, the checkbox and readiobuttonlist fields do not)

   
    'Update Text Field
    Set field2 = jso.getField("form1[0].#subform[1].#field[16]")
    field2.Value = "Field_16"  ' assign the fields value
   
    'Update Checkbox field
    Set field2 = jso.getField("form1[0].#subform[1].CheckBox1[0]")
    field2.Value = 1  ' assign the fields value

    'Update Radiobuttonlist field
    Set field2 = jso.getField("form1[0].#subform[1].RadioButtonList1[2]")
    field2.Value = 22  ' assign the fields value
   
    'Save the changes to the form
    theForm.Save PDSaveIncremental, cPDF
0
Comment
Question by:Charly999
  • 6
  • 4
10 Comments
 
LVL 57
ID: 38841321
No takers yet?   Let me see if I can't figure it out....

Jim.
0
 
LVL 57
ID: 38841394
Basically the code is sound.  Try passing it as text:

   'Update Checkbox field
    Set field2 = jso.getField("form1[0].#subform[1].CheckBox1[0]")
    field2.Value = "1"  ' assign the fields value

    'Update Radiobuttonlist field
    Set field2 = jso.getField("form1[0].#subform[1].RadioButtonList1[2]")
    field2.Value = "22"  ' assign the fields value

Jim.
0
 

Author Comment

by:Charly999
ID: 38841600
Jim, appreciate the feed back. I have dug deeper, and have found several things:

 1) I can see the updates in the PDF form when I have it open and I'm running the VBA code from MS Access.

  2) Problem seems to be when saving the form, the checkboxes and readiobutton values roll back to the initial values, so the updated values are lost.

  3) Others sites suggest the problem is with the checkboxes and radiobuttons being on the Master page in the pdf document.and therefore can't be updated using the above coding. They suggest using javascript.

So, I have tried javascript and that doesn't seem to be working either. The pdf is created by another group via livecycle, and I can't edit it in to place the controls on a design page.

Any help would be greatly appreciated. If you know the syntax for using javascript to update a specific checkbox on a form, that wouid help.

Thanks

Charly
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 57
ID: 38843828
Your working in a area with PDF's that I've never dealt with, so I really don't have anything to offer.

I'd have to have the PDF your working with and the code and take a stab at it to get anywhere.

Jim.
0
 

Author Comment

by:Charly999
ID: 38852064
Jim, here is code from the net and attached form. Does not seem to want to work. Thanks.


Public Sub Test2FromNet()

Dim FV, fn, txt

Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "Acrobat.exe C:\Temp\TestFile.pdf"
 
  '// Set/Get Acrobat Objects
Set App = CreateObject("AcroExch.App")
Set AVDoc = App.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set jso = PDDoc.GetJSObject

  '// search for fields and get Name+value
txt = ""
If jso.numFields Then
  For i = 0 To jso.numFields - 1
     txt = ""
     fn = jso.getNthFieldName(i)
     Set f = jso.getField(fn)
     FV = f.Value
     If f.Type = "checkbox" Then
        f.Value = 1
    End If
     txt = txt & fn & "=" & FV & ";"
     'MsgBox (txt)
  Next
Else
  MsgBox ("No fields found")
End If


PDDoc.Save PDSaveIncremental, "C:\Temp\TestFile.pdf"
 
Set AVDoc = Nothing
Set PDDoc = Nothing
Set jso = Nothing

End Sub
0
 
LVL 57
ID: 38852566
Don't see an attachment...

Jim.
0
 

Author Comment

by:Charly999
ID: 38856488
Trying again w attachement. Selecting file from the "Browse" button, Clicking "Attach", seeing the barber pole spin, watching the browser status bar run out. Looks to me like it worked, but maybe not. I'll try again.
0
 

Author Comment

by:Charly999
ID: 38856853
Ok, attached added.
TestFile.pdf
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38857101
Hum, not sure what to tell you.  Code below seemed to work fine here.  Unchecked all the check boxes, save, re-opened and verified saved as un-checked, then ran the code.  All the boxes from "Category(s) of info:" and below were checked.

Jim.

Public Sub Test2FromNet()

Dim wshshell As Object
Dim app As Object
Dim AVDoc As Object
Dim PDDoc As Object
Dim jso As Object
Dim i As Integer
Dim f As Object

Dim FV, fn, txt

Const PDSaveIncremental = 0
 
Const PDSaveFull = 1
Const PDSaveCopy = 2
Const PDSaveLinearized = 4
Const PDSaveWithPSHeader = 8
Const PDSaveBinaryOK = 16
Const PDSaveCollectGarbage = 32
Const PDSaveForceIncremental = 64
Const PDSaveKeepModDate = 128

Set wshshell = CreateObject("Wscript.Shell")
wshshell.Run "Acrobat.exe C:\Temp\TestFile.pdf"
 
'// Set/Get Acrobat Objects
Set app = CreateObject("AcroExch.App")
Set AVDoc = app.GetActiveDoc
Set PDDoc = AVDoc.GetPDDoc
Set jso = PDDoc.GetJSObject

'// search for fields and get Name+value
txt = ""
If jso.numFields Then
  For i = 0 To jso.numFields - 1
     txt = ""
     fn = jso.getNthFieldName(i)
     Set f = jso.getField(fn)
     FV = f.Value
     If f.Type = "checkbox" Then
        f.Value = 1
    End If
     txt = txt & fn & "=" & FV & ";"
     Debug.Print txt
  Next
Else
  MsgBox ("No fields found")
End If

PDDoc.Save PDSaveIncremental, "C:\Temp\TestFile.pdf"

PDDoc.Close
Set PDDoc = Nothing
Set jso = Nothing
Set AVDoc = Nothing
Set app = Nothing


End Sub
0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38857107
I should note however that I have Acrobat Standard installed on the machine I tested this on.

Jim.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question