Best method for looping through checkboxes

S

spunkymuffmonkey

Hi community, hope we're all well and happy!

I have a document with 60 formfield checkboxes that I require to loop
through to ascertain their value.

I plan to create an array and then use a loop like this and wondered if this
is most efficient/fastest way of doing this, any advice/guidance would be
greatyl apprieciated.

Dim oDoc As Document
Dim blnCheck(0 To 29) As Boolean

Set oDoc = Application.ActiveDocument
y = 0
For i = 34 To 153 Step 4
blnCheck(y) = CBool(oDoc.FormFields("Check" & i).CheckBox.Value)
y = y + 1
Next i

Set oDoc = Nothing
 
S

spunkymuffmonkey

I forgot to mention that I only require to know a value for every 4
checkboxes and intend to return values into an array, correcting my code:

Sub ReadContents()
Dim oDoc As Document
Set oDoc = Application.ActiveDocument
y = 0
For i = 34 To 153 Step 4
blnCheck(y) = CBool(oDoc.FormFields("Check" & i).CheckBox.Value)
y = y + 1
Next i

Set oDoc = Nothing

End Sub
 

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