# Help with MS Word form field conditional formatting.



## mike872208 (Dec 31, 2011)

I am using MS Word to create a protected document. I am setting it up using "Form Fields". I would like to find a way to format the form field to a certain font color based on the entry into the field. 

For example: For a range of 10-20, I would like the text to be green, but any number outside of this range, I would like the text to be red.

Any help would be greatly appreciated.


----------



## macropod (Apr 11, 2008)

Hi Mike,

You could do that via an 'on exit' macro attached to the formfield and coded as:

```
Sub ConditionalFormat()
With ActiveDocument.FormFields("Text1")
  If Abs(.Result - 15) <= 5 Then
    .Range.Font.ColorIndex = wdGreen
  Else
    .Range.Font.ColorIndex = wdRed
  End If
End With
End Sub
```
where 'Text1' is the formfields internal bookmark name.


----------

