#1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Dmitry Osipov
 
Posts: n/a
Default Assigning Color

Is there a way to assign a specific color to a table cell, depending on the
value of the merge field? Say, my UserType field can be of five possible
values and I want to color code the table cell that contains this field.
Appreciate any help.


  #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

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
cell's background color not printed correctly [email protected] Tables 2 December 19th 05 12:44 PM
Color Printing Chris Pohlad-Thomas Formatting Long Documents 2 October 31st 05 03:36 PM
Color Printing Chris Pohlad-Thomas Page Layout 2 October 31st 05 03:36 PM
display one font color on the monitor but print in another lmf001 Microsoft Word Help 1 June 7th 05 03:46 AM
Default background color in Word DuBojangles Microsoft Word Help 3 December 6th 04 12:45 AM


All times are GMT +1. The time now is 10:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"