PDA

View Full Version : Excel Userform with Checkbox value, How to return to Checkbox value in Winword



justuptou
06-11-2019, 06:44 AM
How to use Excel Userform with Checkbox / Option Button value,
then return value to Checkbox / Textbox / Option Button in Winword Form

1) Use the "Print Report" Button, Red Box in figure
2) Get the Checkbox value from Excel Userform
3) Print the information onto Winword Application form. Green & Blue Box in figure
4) I know below coding is not correct, But I am trying to explain my wishes.

Pseudo Code (https://www.google.com/search?safe=strict&rlz=1C1VFKB_enHK628HK628&q=Pseudo+Code&spell=1&sa=X&ved=0ahUKEwjVu4qdxuHiAhWPMN4KHdTkBG0QkeECCCwoAA):
:
:
:
' Green Box in figure
If Optionbutton1.value = true then
doc.tables(1).Cell(4,2).Optionbutton1.value = True
Else
doc.tables(1).Cell(4,2).Optionbutton2.value = False
End if

' Blue Box in figure
If Checkbox1.value = True then
doc.tables(1).Cell(6,1).CheckBox1.value = True
Else
doc.tables(1).Cell(6,1).CheckBox1.value = False
End if

If Checkbox2.value = True then
doc.tables(1).Cell(6,2).CheckBox2.value = True
Else
doc.tables(1).Cell(6,2).CheckBox2.value = False
End if
:
:
:
If Checkbox6.value = True then
doc.tables(1).Cell(7,3).CheckBox6.value = True
Else
doc.tables(1).Cell(7,3).CheckBox6.value = False
End if
:
:
:

justuptou
06-11-2019, 06:03 PM
Master,

Pls guide me how to fix the request.

I would like someone who can answer me or you can says no method to do this for VBA, I m worry about the case long time .

大灰狼1976
06-11-2019, 06:33 PM
Hi justuptou!
ActiveX controls on the same document have unique names,
So you can assign values directly to controls like below:

ActiveDocument.OptionButton1 = True

大灰狼1976
06-12-2019, 06:46 PM
Please refer to the attachment.