Only print data on a form when the check box has been selected.

K

Kerrie Wood 45693

I have a form in Word 2003 that I have been asked to configure. Until now
when data from a group of check boxes was selected the person selecting it
had to delete the other option they did not check. Is there a way that I can
automate it so only the text in the cell where the check box is shows up on
the printed copy?

At the moment the Check box is in one cell of the table and the text is in
another cell directly next to it. I am able to merge the cells together if
this is what is needed unless I can leave them seperate and still achieve
what I need. I only want the text that is checked to print out.

I hope I have explained this correctly.

I would appreciate any assistance.

Thanks,
Kerrie
 
G

Graham Mayor

You will need macros to do this. Without knowing how your table is set up I
can only offer rough guidelines. The following macro run on exit from each
of the check box fields will evaluate the setting of the check box and hide
or display the text in the associated column defined in the macro.
http://www.gmayor.com/installing_macro.htm

The macro requires you to set two parameters.
1. Set the number of the COLUMN containing text to be hidden or displayed in
the line iCol= (here shown as Column 2)
2. Name the check box form fields to end in a number that matches the ROW of
the table in which the check box field is located. The macro as written will
work with number 1 to 9. If you have more check boxes than can be
encompassed by those numbers, add a zero in front of the numbers 1-9 and
continue to 99
then change the line
mstrFF = Right(GetCurrentFF.name, 1)
to
mstrFF = Right(GetCurrentFF.name, 2)

Private mstrFF As String
Public Sub CBOnExit()
Dim bHiddenP As Boolean
Dim bHiddenV As Boolean
Dim bProtected As Boolean
Dim iCol As Integer
With GetCurrentFF
mstrFF = Right(GetCurrentFF.name, 1)
iCol = 2
bHiddenP = Options.PrintHiddenText
bHiddenV = ActiveWindow.View.ShowHiddenText
Options.PrintHiddenText = False
ActiveWindow.View.ShowHiddenText = False
If ActiveDocument.ProtectionType <> wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
If .CheckBox.Value = True Then
ActiveDocument.Tables(1).Cell(mstrFF, 2).Range.Font.Hidden = False
Else
ActiveDocument.Tables(1).Cell(mstrFF, 2).Range.Font.Hidden = True
End If
Options.PrintHiddenText = bHiddenP
ActiveWindow.View.ShowHiddenText = bHiddenV
'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
End With
End Sub

Private Function GetCurrentFF() As Word.FormField
Dim rngFF As Word.Range
Dim fldFF As Word.FormField
Set rngFF = Selection.Range
rngFF.Expand wdParagraph
For Each fldFF In rngFF.FormFields
Set GetCurrentFF = fldFF
Exit For
Next
End Function

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.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