I should have asked what code you were using to get the check boxes to
behave in an exclusive fashion, but it sounds like it might be the following
code that I quite often suggest to which I have added a msgbox command to
display the number 1, 2, 3, or 4 of the box that was checked. The code
assumes that the checkboxes have bookmark names of
CHK####A, CHK####B, CHK####C, CHK####D
where #### is a four digit number, which is unique for each group of
checkboxes.
You could use the Asc(ChkCode) - 64 to get the number for your chart input.
Sub ExclusiveCheckBoxes()
Dim ChkCode As String
Dim ChkStart As String
Dim frmFld As FormField
Dim LtrStr As String
Dim NextChk As String
Dim tmpFrmFld As FormField
LtrStr = "ABCDE"
Set frmFld = Selection.FormFields(1)
' Did something happen?
If frmFld.Result > 0 Then
ChkName = frmFld.Name
If UCase(Left(ChkName, 3)) = "CHK" Then
ChkStart = Left(ChkName, 7): ChkCode = UCase(Right(ChkName, 1))
Select Case ChkCode
Case "A", "B", "C", "D", "E"
' Find all the other members of this group and clear them - yes
this will also clear the selected checkbox
For i = 1 To Len(LtrStr)
NextChk = ChkStart & Mid(LtrStr, i, 1)
' MsgBox NextChk
If ActiveDocument.Bookmarks.Exists(NextChk) Then
Set tmpFrmFld = ActiveDocument.FormFields(NextChk)
tmpFrmFld.CheckBox.Value = False
End If
Next i
' Set the check box that was selected
frmFld.CheckBox.Value = True
Case Else
End Select
MsgBox "The number of the box that is checked is No. " &
Asc(ChkCode) - 64
End If
End If
End Sub
When I suggest the use of this code, I also suggest the use of the following
code to insert each checkbox
Sub InsertExclusiveCheckBox()
'
Dim BMName As String
Dim chkff As FormField
BMName = "chk" & InputBox("Enter the Group and CheckBox Identifier in the
form of a four digit number followed by a character A, B, C, D or E",
"Mutually Exclusive Checkbox")
If ActiveDocument.Bookmarks.Exists(BMName) Then
MsgBox "A Checkbox with the identifier " & BMName & " already exists in
the form."
Exit Sub
Else
Set chkff = ActiveDocument.FormFields.Add(Selection.Range,
wdFieldFormCheckBox)
With chkff
.Name = BMName
.EntryMacro = "ExclusiveCheckBoxes"
End With
End If
End Sub
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP, originally posted via msnews.microsoft.com