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

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