![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
How to get the MS word document checkbox form element associated text value. I am able to extract the value of the checkbox. I tried with bookmark and name properties and found that there is no value associated with bookmark filed of the checkbox. I got the following output. Any thoughts?
Sub Test() Dim strCheckBoxName As String Dim strCheckBoxValue As String For i = 1 To ActiveDocument.FormFields.Count If ActiveDocument.FormFields(i).CheckBox Then strCheckBoxName = ActiveDocument.FormFields(i).Name strCheckBoxValue = ActiveDocument.FormFields(i).CheckBox.Value Debug.Print strCheckBoxName & " = " & strCheckBoxValue End If Next End Sub Output: Check1 = True Check1 = True Check1 = True Check1 = False Check1 = False Check1 = False Solution looking for: A = True B = True C = True D = False E = False F = False Thanks for your help. |
|
#2
|
||||
|
||||
|
What you require is as follows. The names will depend on what you have called the check boxes. The default is Checkn where n is an incrementing number
Code:
Sub Test()
'Graham Mayor - http://www.gmayor.com - Last updated - 25/11/2016
Dim oFF As FormField
Dim strCheckBoxName As String
Dim strCheckBoxValue As String
Dim i As Long
For i = 1 To ActiveDocument.FormFields.Count
Set oFF = ActiveDocument.FormFields(i)
If oFF.Type = wdFieldFormCheckBox Then
strCheckBoxName = oFF.Name
strCheckBoxValue = oFF.CheckBox.Value
Debug.Print strCheckBoxName & " = " & strCheckBoxValue
End If
Next
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Macro to keep formatted form fields after mail merge or replace text with formatted form fields | jer85 | Word VBA | 2 | 04-05-2015 10:00 PM |
| Entering HELP Text for Word 2010 form fields | slandi | Word | 0 | 03-28-2014 08:09 AM |
| Duplicating form fields (check-boxes) | Jānis | Word | 3 | 09-16-2012 12:09 PM |
Cannot enter text into form fields, Word 2007
|
mjr55 | Word | 7 | 04-19-2012 04:24 PM |
Form Fields - Create blank form text field with if statement?
|
LAssist2011 | Word | 5 | 12-14-2011 03:02 PM |