Form using Form Controls to highlight selected option

M

Mifty

Hi everyone,

I'm very new but enthusiastic so may be asking too much or biting off more
than I can chew.

What I've been asked to do is to find a way that users can highlight areas
of text in a five column table where each row is a choice about how they
descibe themselves. The person who wants the work done would like the chosen
answer to highlight in yellow without the user having to do it manually
(Large questionnaire and having it automated increases chances of getting it
filled in)

What I thought of doing was to add tickboxes but this was not thought to be
visual enough.

Is there any way to do it through code so that where a tick box has been
checked adjacent text in the cell is highlighted?

Thank you :)
 
J

Jean-Guy Marcil

Mifty said:
Hi everyone,

I'm very new but enthusiastic so may be asking too much or biting off more
than I can chew.

What I've been asked to do is to find a way that users can highlight areas
of text in a five column table where each row is a choice about how they
descibe themselves. The person who wants the work done would like the chosen
answer to highlight in yellow without the user having to do it manually
(Large questionnaire and having it automated increases chances of getting it
filled in)

What I thought of doing was to add tickboxes but this was not thought to be
visual enough.

Is there any way to do it through code so that where a tick box has been
checked adjacent text in the cell is highlighted?

You did not mention whether you are working with a Protected form or not. I
will assume that you are not.

Here is one way of doing things:

Add a borderless column to the left of the table.
For each row were you want to toggle the visual display, insert a checkbox
from the Controls Toolbox (View > Toolbars...).
Each checkbox will be automatically named CheckBox1, CheckBox2, CheckBox3,
etc.
Use the following code. If you do not want the area behind the checkbox to
be shaded, you will need to modify the code. Make sure that the name of each
sub eflects the name of the checkbox in your table.
Also, do not forget to toggle Design mode (The first button on the Controls
Toolbox toolbar) or the code will not run (and the check mark will not appear
in the box).


Private Sub CheckBox1_Click()

ToggleFill CheckBox1.Value

End Sub

Private Sub CheckBox2_Click()

ToggleFill CheckBox2.Value

End Sub

Private Sub CheckBox3_Click()

ToggleFill CheckBox3.Value

End Sub


Sub ToggleFill(boolToggle As Boolean)

If boolToggle Then
With Selection.Rows(1).Range.Shading
.Texture = wdTextureNone
.BackgroundPatternColor = wdColorAutomatic
.ForegroundPatternColor = wdColorLightYellow
End With
Else
With Selection.Rows(1).Range.Shading
.Texture = wdTextureNone
.BackgroundPatternColor = wdColorAutomatic
.ForegroundPatternColor = wdColorWhite
End With
End If

End Sub
 
M

Mifty

Hi Jean-Guy

Merci for responding.

I've tried out the code, really neat, I changed the Rows to Cells so that it
highlights just one cell instead of the whole row.

I may be re-thinking how I'm going to do this though, I'll probably post
another question.

Thank you again
 

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