S
Sam Schroder
I have the following code to validate a row of checkboxes (customer wants checkboxes; not radio buttons). It makes sure that the boxes in the row (5 boxes in a row) are mutually exclusive, then copies the results to a summary page. I have set up the checkboxes with Entry macro as below and "calculate on exit". The code works, but there seems to be a lot of "chugging" going on. Since I am brand new to Word macros, I'm wondering if maybe the code is not the efficient way to do it. If someone could tell me if I'm on the right track, or should be doing something differently....
Dim objField As FormField
Dim curName As String
Dim sumName As String
'
' First set all checkboxes in the row to false
For Each objField In Selection.Rows(1).Range.FormFields
If objField.Type = wdFieldFormCheckBox Then
objField.CheckBox.Value = False
End If
Next objField
'
' Now set the selected box to a check mark
Selection.FormFields(1).CheckBox.Value = True
'
' Get the base name for the current field
' and the corresponding summary field
curName = Mid(Selection.FormFields(1).Name, 1, 4)
sumName = curName & "Sum"
'
' Transfer the final values to the summary page
For i = 1 To 5
ActiveDocument.FormFields(sumName & i).CheckBox.Value = ActiveDocument.FormFields(curName & i).CheckBox.Value
Next i
EggHeadCafe - Software Developer Portal of Choice
C# Dev Guide to ASP.NET/ADO.NET/XML
http://www.eggheadcafe.com/tutorial...b75c-62447b32e36f/c-dev-guide-to-aspneta.aspx
Dim objField As FormField
Dim curName As String
Dim sumName As String
'
' First set all checkboxes in the row to false
For Each objField In Selection.Rows(1).Range.FormFields
If objField.Type = wdFieldFormCheckBox Then
objField.CheckBox.Value = False
End If
Next objField
'
' Now set the selected box to a check mark
Selection.FormFields(1).CheckBox.Value = True
'
' Get the base name for the current field
' and the corresponding summary field
curName = Mid(Selection.FormFields(1).Name, 1, 4)
sumName = curName & "Sum"
'
' Transfer the final values to the summary page
For i = 1 To 5
ActiveDocument.FormFields(sumName & i).CheckBox.Value = ActiveDocument.FormFields(curName & i).CheckBox.Value
Next i
EggHeadCafe - Software Developer Portal of Choice
C# Dev Guide to ASP.NET/ADO.NET/XML
http://www.eggheadcafe.com/tutorial...b75c-62447b32e36f/c-dev-guide-to-aspneta.aspx