Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loop Through all check boxes

1,439 views
Skip to first unread message

Skip

unread,
Oct 19, 2004, 10:37:02 AM10/19/04
to
I have several check boxes on a form. I need to loop through them with a
certain groupname and check the values of each.
Thanks For any Direction

Skip

Skip

unread,
Oct 19, 2004, 12:51:04 PM10/19/04
to
Thanks Chuck,

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

Skip

unread,
Oct 19, 2004, 12:53:03 PM10/19/04
to
Thanks Chuck,

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:
>

Martin Seelhofer

unread,
Oct 21, 2004, 3:00:19 AM10/21/04
to
Hi there

> 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


Skip

unread,
Oct 21, 2004, 9:03:03 AM10/21/04
to
Thanks Martin,
But no matter what I do ActiveDocument.FormFields is always zero.
any ideas?

Martin Seelhofer

unread,
Oct 21, 2004, 11:08:01 AM10/21/04
to
Hi again

> 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


Skip

unread,
Oct 21, 2004, 11:23:06 AM10/21/04
to
THANK YOU THANK YOU THANK YOU!
Life is good now!
Skip

iris

unread,
Jan 27, 2010, 4:35:06 AM1/27/10
to
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?

Fumei2 via OfficeKB.com

unread,
Jan 28, 2010, 1:27:01 PM1/28/10
to
Userform controls are ActiveX controls.

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

0 new messages