Jan Ondracek
Jan Ondracek

Reputation: 21

Radio button value, vba excel, acrobat pro

I need to download content of .pdf documents programmatically using vba run from Excel. I have an Adobe Acrobat Pro licence which provides libraries to Excel so one is able to work with .pdf documents using vba in Excel. I can very well extract data from text fields using jso.getField:

Dim AcroApp As Acrobat.CAcroApp
Dim theForm As Acrobat.CAcroPDDoc
Dim jso As Object
Dim text1 As String

Set AcroApp = CreateObject("AcroExch.App")
Set theForm = CreateObject("AcroExch.PDDoc")
theForm.Open ("C:\Users\....path…\file.pdf")
Set jso = theForm.GetJSObject

text1 = jso.getField("fill_1").Value

…unfortunately there are also radiobuttnos in the .pdf files which I don’t know how to access and retrieve it’s values. All the text fields can be referenced easily with e.g. “fill_1” whereas the radiobuttons are structured like Group1 -> Value1 ->Value2.

I also need to access radiobutton values, without that I am a bit stack :(.

Thank you very much for any advice

Jan

Upvotes: 1

Views: 512

Answers (1)

Codedogs
Codedogs

Reputation: 139

Let's assume there is a group of 3 radio buttons in the PDF form called "My_Options". Each option is named as follows

  • "Option_1"
  • "Option_2"
  • "Option_3" Let us assume "Option_2" is selected.

To ask which button is selected in VBA:

dim Text as string
Text = jso.getField("My_Options").Value

This returns Text = "Option_2"

To set "Option_3" as selected in VBA:

jso.getField("My_Options").Value = "Option_3"

Upvotes: 0

Related Questions