Skip
I believe I am on the right path but...
I have a Word Document with a table. Inside each row/column I have a check
box.
How do I loop through each of the check boxes in the Word Document and check
the value.
Thanks Again!
Skip
"chuck" wrote:
> If the check boxes as inside a frame then this will do it.
> If the check boxes are just on the form then change the
> frame name to the name of the form.
>
> Dim Ctrl as Variant
> For Each Ctrl In FrameName.Controls
> If TypeName(Ctrl) = "CheckBox" Then
> If Ctrl.Value = True Then
> 'do something
> Else 'it's false
> 'do something
> End If
> End If
> Next
I think you have me on the right path but...
I have a Word Document with a table
Each row/column of the table has a checkbox.
How do I check the value of each checkbox if a loop?
Thanks Again
Skip
"chuck" wrote:
> If the check boxes as inside a frame then this will do it.
> If the check boxes are just on the form then change the
> frame name to the name of the form.
>
> Dim Ctrl as Variant
> For Each Ctrl In FrameName.Controls
> If TypeName(Ctrl) = "CheckBox" Then
> If Ctrl.Value = True Then
> 'do something
> Else 'it's false
> 'do something
> End If
> End If
> Next
>
>
> On Tue, 19 Oct 2004 07:37:02 -0700, "Skip"
> <Sk...@discussions.microsoft.com> wrote:
>
> I have a Word Document with a table
> Each row/column of the table has a checkbox.
> How do I check the value of each checkbox if a loop?
In this case (FormFields, not UserForms), use something like:
Dim fld As FormField
For Each fld in ActiveDocument.FormFields
If fld.Type = wdFieldFormCheckBox Then
Debug.Print fld.CheckBox.Value
End If
Next
Cheers,
Martin
> But no matter what I do ActiveDocument.FormFields is always zero.
> any ideas?
A third possibility is that you are not using FormFields but ActiveX-
Controls instead. In this case, the following - more complicated - approach
might help (mind the possibly introduced line breaks):
Sub enumCheckboxValues()
Dim chk As msforms.CheckBox
Dim ish As InlineShape
' loop through all inline objects
For Each ish In ActiveDocument.InlineShapes
' check if we are dealing with ActiveX-controls
If ish.Type = wdInlineShapeOLEControlObject Then
' Yes --> check if we are dealing with a checkbox
If ish.OLEFormat.ClassType Like "Forms.CheckBox*" Then
' Yes --> access the Checkbox object
Set chk = ish.OLEFormat.Object
' ... and do something with it, e.g. print out its value
Debug.Print chk.Caption & ": " & chk.Value
End If
End If
Next
End Sub
Note that the above routine works only with inline shapes (e.g. ActiveX
controls embedded into the text). If you used floating controls, you'll
have to change some things:
- Replace InlineShape with Shape / InlineShapes with Shapes
- Replace wdInlineShapeOLEControlObject with msoOLEControlObject
HTH,
Martin
I have a question about activex controls.
I hope you can help me.
In word 2000 There are activex controls only in the document fields.
when I am creating a user form - there is no indication that the fields are
activex controls.
Am I to assume that when Im working with user forms activex is included
automatically?
Or should I incorporate it in the form in some other way?
iris wrote:
>Hi Martin.
>
>I have a question about activex controls.
>I hope you can help me.
>
>In word 2000 There are activex controls only in the document fields.
>when I am creating a user form - there is no indication that the fields are
>activex controls.
>
>Am I to assume that when Im working with user forms activex is included
>automatically?
>Or should I incorporate it in the form in some other way?
>
>> Hi again
>>
>[quoted text clipped - 31 lines]
>> HTH,
>> Martin
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/201001/1