[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

MS Access VBA to update Adobe form checkbox and radiobuttonlist

Posted on 2013-01-30
10
Medium Priority
?
1,761 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 58
ID: 38841321
No takers yet?   Let me see if I can't figure it out....

Jim.
0
 
LVL 58
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
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 58
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 58
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 58

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 1500 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 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

656 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