Hi Preacherman
You can achieve what you want without a macro, if you have Word 2002 or
2003. To do that, select the whole table. Use Edit > Find. In the Find What
box, type your "XX" text. Tick the "Highlight all items found in" box (which
should say "Current selection"). Click Find All, and then Close. You'll see
that Word has selected all cells containing "XX". Now, use Format > Borders
and Shading to shade the cells.
However, if you need a macro to do this, you could use the following code.
You'll need to change XX to the text you need to find.
Sub FindTextInATableAndShadeCell()
' Posted to microsoft.public.word.tables newsgroup
' Shauna Kelly 15/8/2004.
Dim oCell As Cell
Dim sTextToFind As String
If Selection.Information(wdWithInTable) = False Then
MsgBox "Cursor is not currently in a table"
Else
sTextToFind = "XX"
'Find cells in the current table that contain
'sTextToFind, and shade the cell
Selection.Tables(1).Select
With Selection.Find
.ClearFormatting
.Text = sTextToFind
.Wrap = wdFindStop
Do While .Execute
Selection.Cells(1).Shading.BackgroundPatternColorIndex =
wdGray25
Loop
End With
End If
End Sub
If you're not sure what to do with the macro, see
http://www.gmayor.com/installing_macro.htm and
http://www.mvps.org/word/FAQs/MacrosVBA/CreateAMacro.htm
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word