I have a table cell with a drop down field with four options (good, caution,
problem, fix). Depending on the user's pick, I want the table cell to change:
If good then green
If caution, then yellow
etc.
What is the code to do this?

Signature
Debra Ann
Debra Ann - 07 Feb 2008 13:27 GMT
Sorry, I meant to say ... I want the table cell "color" to change.

Signature
Debra Ann
> I have a table cell with a drop down field with four options (good, caution,
> problem, fix). Depending on the user's pick, I want the table cell to change:
[quoted text clipped - 4 lines]
>
> What is the code to do this?
Greg Maxey - 07 Feb 2008 21:44 GMT
Something like this:
Option Explicit
Public mstrFF As String
'Run on exit from your DD field
Public Sub AOnExit()
Dim oDoc As Word.Document
Dim oCell As Cell
Set oCell = ActiveDocument.Tables(1).Cell(1, 1)
Set oDoc = ActiveDocument
oDoc.Unprotect
With GetCurrentFF
Select Case .Name
Case Is = "MyDropDown"
Select Case .Result
Case Is = "good"
oCell.Shading.BackgroundPatternColor = wdColorGreen
Case Is = "caution"
oCell.Shading.BackgroundPatternColor = wdColorYellow
Case Else
'Whatever
End Select
Case Else
'Whatever
End Select
End With
oDoc.Protect wdAllowOnlyFormFields, True
End Sub
Public Function GetCurrentFF() As Word.FormField
With Selection
If .FormFields.Count = 1 Then
Set GetCurrentFF = .FormFields(1)
ElseIf .FormFields.Count = 0 And .Bookmarks.Count > 0 Then
Set GetCurrentFF = ActiveDocument.FormFields _
(.Bookmarks(.Bookmarks.Count).Name)
End If
End With
End Function

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> I have a table cell with a drop down field with four options (good,
> caution, problem, fix). Depending on the user's pick, I want the
[quoted text clipped - 5 lines]
>
> What is the code to do this?