Check Boxes - How to add them up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have several check boxes and need to have a way to add up how many boxes
are checked automatically and display that information in the header of the
document. Any idea's on how to do this?

Thank you in advance.
 
With a macro something like this and a DocVariable field in the
header:

Sub CalcCBs()
Dim oFF As FormField
Dim oFFs As FormFields
Dim i As Long
'Dim oChkCount As Variable
Set oFFs = ActiveDocument.FormFields
For Each oFF In oFFs
If oFF.Type = wdFieldFormCheckBox Then
If oFF.CheckBox.Value = True Then i = i + 1
End If
Next oFF
ActiveDocument.Variables("oCheckCount").Value = i
ActiveDocument.Unprotect
ActiveDocument.StoryRanges(wdPrimaryHeaderStory).Fields.Update
ActiveDocument.Protect wdAllowOnlyFormFields, NoReset:=True
End Sub

The field is inserted using CTRL+F9. In the braces type { DocVariable
oCheckCount }
You could set this macro to run on exit from the individual checkboxes
but "the automatic" part would require that the user physically exited
from the last check box accessed or your count would be off. If you
have you a more complicated page setup (other header types) you would
need to update the specific storyRange that holds your DocVariable
field.
 

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

Similar Threads

Check boxes to text 2
Word 2003 Form Fields 1
Check box 5
linking check boxes 0
How to add a check-box in word? 3
Check box help in Word 2007 2
Check box question 1
remove check boxes 1

Back
Top