Edit Chart Data in a Word 2007 Template using grouped CheckBoxes

H

Hans

I'm trying to develop a template that asks 7 questions with each having 4
check boxes. I've learned how to have only one box checked at a time but am
having a problem using those inputs to update the data in a Filled Radar
Chart in the document. Can anyone help me with the best way to extract the
CheckBox marks and add that information to the third column of the data table
of that chart?
 
D

Doug Robbins - Word MVP

It would help to know how you have the check boxes arranged in the document,
what type of check boxes they are, etc.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
H

Hans

Here's an example of two of the questions with the boxes. Sorry it didn't
paste so well. The zero's are the boxes.

"Complexity of Problem – A measure of the analytic complexity and uniqueness
of the problem. This includes: Detail Complexity (e.g., it has many parts and
steps) and Dynamic Complexity (e.g., many parts working together in a
changing, often emergent, manner.)
0 Problem has been previously solved, or solution is self evident.
0 Tame problem/puzzle: problems are well understood and well defined. The
method for solving these problems is well known and the solution obvious.
0 Common, but significant, problem one is challenged with on a regular
basis. Problem situations are defined, but the solution is not obvious. The
problem contains significant detail complexity.
0 Wicked problem that cannot be definitively described; responses are not
meaningfully correct or false; no solution in the sense of definitive and
objective answers. The problem contains significant dynamic complexity.

New Knowledge/Understanding – A measure of the new knowledge or
understanding that is generated through the project. Consider the
reach/applicability of the knowledge generated, previous knowledge base in
this problem area, and maturity of discipline or problem domain area
0 Knowledge or conclusions are known.
0 Improvement over existing solution/knowledge. Solution sought from w/in
the problem domain.
0 New concept, solution, or knowledge, but usually includes extending
insights and knowledge from outside the problem domain.
0 Discovery of new insights, knowledge or understanding not previously known."

I found some code to make them exclusive boxes within the question (i.e.
only one box can be checked in each question. The Checkboxes are bookmarked
with the first seven characters the same within each question and then A, B,
C, D as the last character. These questions are in a form box with other
fields and controls. After the form is the Filled Radar chart input manually
that I would like to read the inputs from the check boxes and assign a number
value and input to the data table automatically. If it's easier I can
generate the chart new with the code. Thanks for the help.

Hans
 
H

Hans

Here's the code I used for the exclusive check boxes. I run this on entry
and exit.

Sub ExclusiveCheckBoxes()
Dim pStr As String
Dim oFF As FormField
Dim pGroupID As String
Dim pSequenceID As String
Dim i As Long
Dim pSequenceNext As String
pStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 'Permits up to 26 checkboxes per group
Set oFF = Selection.FormFields(1)
If oFF.CheckBox.Value = True Then
pGroupID = Left(oFF.Name, 7)
pSequenceID = UCase(Right(oFF.Name, 1))
If pSequenceID Like "[A-Z]" Then
'Clear all GroupID ChkBoxes including the CB selected (ensure only one
CB in group is selected).
For i = 1 To Len(pStr)
pSequenceNext = pGroupID & Mid(pStr, i, 1)
If ActiveDocument.Bookmarks.Exists(pSequenceNext) Then
ActiveDocument.FormFields(pSequenceNext).CheckBox.Value = False
End If
Next i
'Set the CB that was selected
oFF.CheckBox.Value = True
End If
End If
End Sub
 
D

Doug Robbins - Word MVP

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
 

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