View Single Post
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor
 
Posts: n/a
Default Conditional Formatting

You don't have a form field called Text1 or in the case of the second macro
Text2. Change the names to match your field names.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


inay wrote:
Hi Greg

When i test the below script by inserting it into a word document i
get an error message 'requested collection not available'. Do you
know what might be causing this?

Thanks,
Yani

"Greg" wrote:

Patricia,

Here is a few macro options that you set to run on exit from the
formfield that should give you a start:

Sub Format()
Dim oDoc As Document
Set oDoc = ActiveDocument
If oDoc.FormFields("Text1").Result "50" Then
oDoc.FormFields("Text1").Range.Font.Color = wdColorBrightGreen
Else
oDoc.FormFields("Text1").Range.Font.Color = wdColorAutomatic
End If
End Sub
Sub ColorField()
Dim content As String
With ActiveDocument.FormFields("Text2")
content = .Result
Select Case LCase(content)
Case "yes":
.Range.Font.Color = wdColorGreen
Case "no":
.Range.Font.Color = wdColorRed
Case Else:
.Range.Font.Color = wdColorAutomatic
End Select
End With
End Sub