Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2006

Tip: Looking for answers? Try searching our database.

Assigning Color

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dmitry Osipov - 20 Mar 2006 18:54 GMT
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.
Greg - 20 Mar 2006 19:45 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.