Thread: Assigning Color
View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Greg
 
Posts: n/a
Default Assigning Color

The following macro looks at the cell at row 1, column 1 and shades the
cell based on a text value. You might adapt it to your needs:

Sub Test()
Dim oTbl As Word.Table
For Each oTbl In ActiveDocument.Tables
MsgBox oTbl.Cell(1, 1).Range.Text
Select Case Left(oTbl.Cell(1, 1).Range.Text, Len(oTbl.Cell(1,
1).Range.Text) - 2)
Case "Apples"
oTbl.Cell(1, 1).Shading.BackgroundPatternColorIndex = wdRed
Case "Lemons"
oTbl.Cell(1, 1).Shading.BackgroundPatternColorIndex = wdYellow
Case Else
'Continue case statements up to Case "5" as appropriate
End Select
Next
End Sub