Prev: Programatic VBA way of telling if the user has Word 2007 PDF add-in installed
Next: Autonew creates a new document from template and a new blank d
From: spunkymuffmonkey on 18 Feb 2010 06:52 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
From: spunkymuffmonkey on 18 Feb 2010 07:04
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 |