Creating a conditional fill-in field

J

jdfranklin

I'm trying to recreate in Word a form I was able to create in Excel. Is it
possible and, if so, how? Here's the behavior I wish to reproduce:

1) A cell has a list of numerical values. If the user selects a value
above a given cutoff point, the cell changes color.
2) In a Yes/No/Uncertain scenario, the cell changes to one color if the
user selects No, and to another color if the user selects Unknown.

I'm going to re-post in the Forms forum in case that's the more appropriate
choice.

Thank you very much.
 
D

Doug Robbins - Word MVP

Assuming that you are talking about a form in a document that is protected
for Filling in Forms, for the first case, have a macro containing the
following code execute on exit from the formfield:

Dim i As Long
Dim acell As Cell
With ActiveDocument
i = .FormFields("Text1").Result
Set acell = Selection.Cells(1)
.Unprotect
With acell.Shading
If i > 9 Then
.BackgroundPatternColor = wdColorRed
Else
.BackgroundPatternColor = wdColorAutomatic
End If
End With
.Protect wdAllowOnlyFormFields, NoReset
End With

For the second case, use the following macro on exit from the formfield:

Dim i As Long
Dim acell As Cell
With ActiveDocument
i = .FormFields("Dropdown1").DropDown.Value
Set acell = Selection.Cells(1)
.Unprotect
With acell.Shading
If i = 1 Then
.BackgroundPatternColor = wdColorGreen
ElseIf i = 2 Then
.BackgroundPatternColor = wdColorRed
Else
.BackgroundPatternColor = wdColorOrange
End If
End With
.Protect wdAllowOnlyFormFields, NoReset
End With



--
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
 

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