Number of check boxes checked

A

A_________

Hi, I'm new to this and would really appreciate your help---

I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are checked. The number
as plain text at the end of the document would do. How can I do this? Thanks
 
C

Cindy M.

Hi =?Utf-8?B?QV9fX19fX19fXw==?=,
I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are checked. The number
as plain text at the end of the document would do.
Version of Word?

What kind of checkboxes are these (which toolbar did you use to insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
A

A_________

Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I translated it into
English from Swedish version's utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]
 
G

Graham Mayor

If you ensure that the checkbox bookmarks are all named the same with the
addition of incrementing numbers (here I have used the default names Check1,
Check2 through to Check 5) then the following macro run on exit from the
last of the check box fields will insert the total number from 5 checked
fields in a form field with the bookmark named Text1

Sub CountChecks()
Dim i As Long
Dim Count As Long
Dim cFields As Integer
Dim cName As String
Dim tName As String

cName = "Check" ' set to common name of check box fields
cFields = 5 'set to the number of check boxes
tName = "Text1" ' name of text box field used _
for the result

Count = 0
For i = 1 To cFields
If ActiveDocument.FormFields(cName & i).CheckBox.Value = True Then
Count = Count + 1
End If
Next i
ActiveDocument.FormFields(tName).Result = Count
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



A_________ said:
Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I translated
it into English from Swedish version's utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]


Cindy M. said:
Hi =?Utf-8?B?QV9fX19fX19fXw==?=,

Version of Word?

What kind of checkboxes are these (which toolbar did you use to
insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
A

A_________

Thanks Graham,
I can see what the macro does but how do I actually make the "macro run on
exit from the last of the check box fields" ?

//Anders

Graham Mayor said:
If you ensure that the checkbox bookmarks are all named the same with the
addition of incrementing numbers (here I have used the default names Check1,
Check2 through to Check 5) then the following macro run on exit from the
last of the check box fields will insert the total number from 5 checked
fields in a form field with the bookmark named Text1

Sub CountChecks()
Dim i As Long
Dim Count As Long
Dim cFields As Integer
Dim cName As String
Dim tName As String

cName = "Check" ' set to common name of check box fields
cFields = 5 'set to the number of check boxes
tName = "Text1" ' name of text box field used _
for the result

Count = 0
For i = 1 To cFields
If ActiveDocument.FormFields(cName & i).CheckBox.Value = True Then
Count = Count + 1
End If
Next i
ActiveDocument.FormFields(tName).Result = Count
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



A_________ said:
Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I translated
it into English from Swedish version's utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]


Cindy M. said:
Hi =?Utf-8?B?QV9fX19fX19fXw==?=,

I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are checked.
The number as plain text at the end of the document would do.

Version of Word?

What kind of checkboxes are these (which toolbar did you use to
insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
A

A_________

Sorry, what I meant was that the macro seems to activate/calculate in a most
random manner and not as a result of exiting the last check box field.
The sum in the text form field changes occationally when checking any
checkbox and the sum is seldom correct. Can't figure out why


A_________ said:
Thanks Graham,
I can see what the macro does but how do I actually make the "macro run on
exit from the last of the check box fields" ?

//Anders

Graham Mayor said:
If you ensure that the checkbox bookmarks are all named the same with the
addition of incrementing numbers (here I have used the default names Check1,
Check2 through to Check 5) then the following macro run on exit from the
last of the check box fields will insert the total number from 5 checked
fields in a form field with the bookmark named Text1

Sub CountChecks()
Dim i As Long
Dim Count As Long
Dim cFields As Integer
Dim cName As String
Dim tName As String

cName = "Check" ' set to common name of check box fields
cFields = 5 'set to the number of check boxes
tName = "Text1" ' name of text box field used _
for the result

Count = 0
For i = 1 To cFields
If ActiveDocument.FormFields(cName & i).CheckBox.Value = True Then
Count = Count + 1
End If
Next i
ActiveDocument.FormFields(tName).Result = Count
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



A_________ said:
Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I translated
it into English from Swedish version's utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]


:

Hi =?Utf-8?B?QV9fX19fX19fXw==?=,

I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are checked.
The number as plain text at the end of the document would do.

Version of Word?

What kind of checkboxes are these (which toolbar did you use to
insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
A

A_________

I tried some variations and finally made the macro "run on entry" (?) instead
of "run on exit". I did this on every checkbox and now the total number of
checked checkboxes updates simultaneously and correctly.

Thanks,
Anders


A_________ said:
Sorry, what I meant was that the macro seems to activate/calculate in a most
random manner and not as a result of exiting the last check box field.
The sum in the text form field changes occationally when checking any
checkbox and the sum is seldom correct. Can't figure out why


A_________ said:
Thanks Graham,
I can see what the macro does but how do I actually make the "macro run on
exit from the last of the check box fields" ?

//Anders

Graham Mayor said:
If you ensure that the checkbox bookmarks are all named the same with the
addition of incrementing numbers (here I have used the default names Check1,
Check2 through to Check 5) then the following macro run on exit from the
last of the check box fields will insert the total number from 5 checked
fields in a form field with the bookmark named Text1

Sub CountChecks()
Dim i As Long
Dim Count As Long
Dim cFields As Integer
Dim cName As String
Dim tName As String

cName = "Check" ' set to common name of check box fields
cFields = 5 'set to the number of check boxes
tName = "Text1" ' name of text box field used _
for the result

Count = 0
For i = 1 To cFields
If ActiveDocument.FormFields(cName & i).CheckBox.Value = True Then
Count = Count + 1
End If
Next i
ActiveDocument.FormFields(tName).Result = Count
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



A_________ wrote:
Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I translated
it into English from Swedish version's utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]


:

Hi =?Utf-8?B?QV9fX19fX19fXw==?=,

I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are checked.
The number as plain text at the end of the document would do.

Version of Word?

What kind of checkboxes are these (which toolbar did you use to
insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)


This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 
G

Graham Mayor

You need to tab out of the field for the macro to run on exit from that
field. If you run on entry to the fields, then the last check box field will
not reflect any change you make to it - unless it loops back to the first
check box.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


A_________ said:
I tried some variations and finally made the macro "run on entry" (?)
instead of "run on exit". I did this on every checkbox and now the
total number of checked checkboxes updates simultaneously and
correctly.

Thanks,
Anders


A_________ said:
Sorry, what I meant was that the macro seems to activate/calculate
in a most random manner and not as a result of exiting the last
check box field.
The sum in the text form field changes occasionally when checking any
checkbox and the sum is seldom correct. Can't figure out why


A_________ said:
Thanks Graham,
I can see what the macro does but how do I actually make the "macro
run on exit from the last of the check box fields" ?

//Anders

:

If you ensure that the checkbox bookmarks are all named the same
with the addition of incrementing numbers (here I have used the
default names Check1, Check2 through to Check 5) then the
following macro run on exit from the last of the check box fields
will insert the total number from 5 checked fields in a form field
with the bookmark named Text1

Sub CountChecks()
Dim i As Long
Dim Count As Long
Dim cFields As Integer
Dim cName As String
Dim tName As String

cName = "Check" ' set to common name of check box fields
cFields = 5 'set to the number of check boxes
tName = "Text1" ' name of text box field used _
for the result

Count = 0
For i = 1 To cFields
If ActiveDocument.FormFields(cName & i).CheckBox.Value =
True Then Count = Count + 1
End If
Next i
ActiveDocument.FormFields(tName).Result = Count
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



A_________ wrote:
Word2007

Checkbox is a FormField inserted from developer>controls>earlier
tools>checkbox(formfield) --- [I hope that is correct, I
translated it into English from Swedish version's
utvecklare>kontroller>tidigare
verktyg>kryssruta(formulärkontroll)]


:

Hi =?Utf-8?B?QV9fX19fX19fXw==?=,

I have a series af check boxes in a MS Word document. I want to
(automatically)display the number of check boxes that are
checked. The number as plain text at the end of the document
would do.

Version of Word?

What kind of checkboxes are these (which toolbar did you use to
insert them)?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17
2005) http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top