Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
I use a word table to track project updates, The fields are "entry
number", "project", "date", and "notes". The table get reviewed by quite a few people and I have a legend at the bottom of the table that shows the color for each project. I would like to be able to enter the project in a cell and have it automatically enter the color code for that project. I know I can do this with Excel but I found it easier to use Word for this process as the table is heavily text oriented. thanks |
#2
![]()
Posted to microsoft.public.word.tables
|
|||
|
|||
![]()
Hi motocrossed,
You can't have Word do that automaticaly for you the way Excel does, but you can run a macro afterwards that applies cell colors depending on the contents of the cell. Sub ColorCells() Dim aTable As Table, aCell As Cell If Selection.Information(wdWithInTable) Then Set aTable = Selection.Tables(1) For Each aCell In aTable.Range.Cells With aCell Select Case UCase(Left(.Range.Text, Len(.Range.Text) - 2)) Case "A" .Shading.BackgroundPatternColor = wdColorAqua Case "B" .Shading.BackgroundPatternColor = RGB(89, 43, 121) Case "C" .Shading.BackgroundPatternColor = RGB(200, 143, 21) Case "D" .Shading.BackgroundPatternColor = wdColorGold Case Else ' white .Shading.BackgroundPatternColor = wdColorWhite End Select End With Next aCell Else MsgBox "Place the cursor in the table, and run the macro again.", _ vbCritical + vbOKOnly, "Color Cells" End If End Sub A few remarks: - Check http://word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm on how to install the macro in Word. The article says "select the template you want to store the macro in" but you can store the macro in your document as well. - Substitute "A", "B", "C" and "D" for your own text in capitals. If you want the macro to be case sensitive, remove "UCase(" and the last ")" from the line Select Case UCase(Left(.Range.Text, Len(.Range.Text) - 2)) and provide your texts the way you want them instead of "A", "B", "C" and "D". - Substitute wdColorX and RGB(R, G, B) for your own colors. If you for example delete "= wdColorAqua" from ".Shading.BackgroundPatternColor = wdColorAqua" and type =, Word displays a list of color constants you can use. You can also make up your own colors by mixing red, green and blue values (0-255) in RGB(R, G, B) - e.g. RGB(255, 255, 255) results in white. - You can of course add more lines like Case X .Shading.BackgroundPatternColor = Y to the list. Good luck, Cooz "motocrossed" wrote: I use a word table to track project updates, The fields are "entry number", "project", "date", and "notes". The table get reviewed by quite a few people and I have a legend at the bottom of the table that shows the color for each project. I would like to be able to enter the project in a cell and have it automatically enter the color code for that project. I know I can do this with Excel but I found it easier to use Word for this process as the table is heavily text oriented. thanks |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Cell border confusion after cells are merged | Tables | |||
I want text from the cells in one table repeated in other tables | Tables | |||
cell's background color not printed correctly | Tables | |||
Insert Column when merged cells exist | Tables | |||
Linking Excel cells to a Word document | Mailmerge |