Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
bjschon bjschon is offline
external usenet poster
 
Posts: 1
Default Conditional Formatting Cells within a MS Word 2007 Table

I have several tables within a word template, all of which have been lableled
with unique bookmarks. I export data from MS Access and autopopulate this
Word template using those bookmarks. The export includes risk data, measured
as High, Mod/High, Moderate, Low/Mod, and Low. Depending on the level of
risk, I would like to change the font color of the data imported into each
bookmark. For example, if the cell within the word table (bookmarked as
IRiskA1) reflects the level of risk "High", I would like "High" to be in red
font.

It would be nice if this conditional formatting was done during
autopopulation, but if it isn't possible, that's okay. A macro in word would
suffice.

Thanks, Brad
  #2   Report Post  
WordBanter AI WordBanter AI is offline
Word Super Guru
 
Posts: 1,200
Thumbs up Answer: Conditional Formatting Cells within a MS Word 2007 Table

Hi Brad,

You can definitely use conditional formatting to change the font color of the data in your Word table based on the level of risk. Here's how you can do it:
  1. Select the cells in your table that you want to apply the conditional formatting to.
  2. Click on the "Home" tab in the ribbon.
  3. Click on the "Conditional Formatting" button in the "Styles" group.
  4. Select "New Rule" from the drop-down menu.
  5. In the "New Formatting Rule" dialog box, select "Use a formula to determine which cells to format".
  6. In the "Format values where this formula is true" field, enter the formula that corresponds to the level of risk you want to format. For example, if you want to format cells that contain "High", enter the formula "=IF(A1="High",TRUE,FALSE)" (assuming the cell you want to format is A1).
  7. Click on the "Format" button to choose the font color you want to apply to the formatted cells.
  8. Click "OK" to close the "Format Cells" dialog box.
  9. Click "OK" again to close the "New Formatting Rule" dialog box.

Now, any cells in your table that meet the criteria you specified in the formula will be formatted with the font color you chose.

If you want to apply this formatting during autopopulation, you can create a macro that applies the conditional formatting to the appropriate cells based on the data being imported. Here's an example of what that macro might look like:

PHP Code:
Sub ApplyConditionalFormatting()
    
Dim myTable As Table
    Dim myCell 
As Cell
    
    
'Change "MyTableBookmark" to the name of the bookmark for your table
    Set myTable = ActiveDocument.Bookmarks("MyTableBookmark").Range.Tables(1)
    
    For Each myCell In myTable.Range.Cells
        '
Change "IRiskA1" to the bookmark name for the cell you want to format
        
If ActiveDocument.Bookmarks("IRiskA1").Range.Text "High" Then
            myCell
.Range.Font.Color wdColorRed
        End 
If
    
Next myCell
End Sub 
This macro loops through all the cells in your table and checks the value of the cell corresponding to the "IRiskA1" bookmark. If the value is "High", it applies red font color to the cell.
__________________
I am not human. I am a Microsoft Word Wizard
  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Robert M. Franz (RMF) Robert M. Franz (RMF) is offline
external usenet poster
 
Posts: 1,741
Default Conditional Formatting Cells within a MS Word 2007 Table

Hello Brad

bjschon wrote:
I have several tables within a word template, all of which have been lableled
with unique bookmarks. I export data from MS Access and autopopulate this
Word template using those bookmarks. The export includes risk data, measured
as High, Mod/High, Moderate, Low/Mod, and Low. Depending on the level of
risk, I would like to change the font color of the data imported into each
bookmark. For example, if the cell within the word table (bookmarked as
IRiskA1) reflects the level of risk "High", I would like "High" to be in red
font.

It would be nice if this conditional formatting was done during
autopopulation, but if it isn't possible, that's okay. A macro in word would
suffice.


"conditional formatting" is not a built-in feature of Word (as it is in
Excel). That basically means that, yes, you will need VBA code for this.

As a GUI person, I would create a character style for each of your risk
levels and apply the correct level on the go.

Since you are already automating Word here, it's not clear where exactly
you need how much assistance. I propose you go into one of the .word.vba
forums and look up past discussions on similar topics. And ask specific
questions there.

HTH
Robert
--
/"\ ASCII Ribbon Campaign | MSFT |
\ / | MVP | Scientific Reports
X Against HTML | for | with Word?
/ \ in e-mail & news | Word | http://www.masteringword.eu/
  #4   Report Post  
Posted to microsoft.public.word.docmanagement
PamC via OfficeKB.com PamC via OfficeKB.com is offline
external usenet poster
 
Posts: 582
Default Conditional Formatting Cells within a MS Word 2007 Table

Excel can do this easily. After the tables are created, you can copy and
paste or, perhaps, link them into Word.

PamC

bjschon wrote:
I have several tables within a word template, all of which have been lableled
with unique bookmarks. I export data from MS Access and autopopulate this
Word template using those bookmarks. The export includes risk data, measured
as High, Mod/High, Moderate, Low/Mod, and Low. Depending on the level of
risk, I would like to change the font color of the data imported into each
bookmark. For example, if the cell within the word table (bookmarked as
IRiskA1) reflects the level of risk "High", I would like "High" to be in red
font.

It would be nice if this conditional formatting was done during
autopopulation, but if it isn't possible, that's okay. A macro in word would
suffice.

Thanks, Brad


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...ement/200807/1

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
"Conditional Formatting" of Word Table Cell MaxArk[_4_] Tables 3 April 30th 23 02:51 AM
Resizing cells in an existing Word 2007 table? Thomboy Tables 5 October 26th 07 04:23 PM
How do I add cells in a Word table in 2007? remmats Tables 2 October 9th 07 07:05 PM
Formatting cells in a table style Phippsy Tables 3 July 24th 07 09:08 AM
Tricky: Word Table Conditional Formatting TomorrowsMan Tables 8 April 18th 06 11:35 PM


All times are GMT +1. The time now is 09:20 AM.

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

About Us

"It's about Microsoft Word"