PDA

View Full Version : Conditional formatting a word table



Elcasperino
05-26-2012, 12:19 PM
I have absolutely no experience of vba, but it seems to be the only way to get want I want within my document so any help would be great. I have a mail merge document within which I have a table, the last column (column 6 if that helps) is filled with merged information - I would like the cells within this column to be conditionally formatted like you can do in excel.

The values in the column are numerical and I would like the cell background colour to change according to the entry:
When less than 0.33 I want the cell colour to be red, when less than 0.66 it turns yellow and less than and equal to 1 then its green.

The relevant cells are conditionally formatted to those rules in the excel file that the information is extracted from so if its easier to preserve the cell colour could that be another option?

Any help would be greatly appreciated

macropod
05-26-2012, 07:10 PM
Hi Elcasperino,

You can conditionally format the mailmerge text's background colour (though not the whole cell) without vba, just using field coding:
{IF{MERGEFIELD MyFld}< "0.33" {MERGEFIELD MyFld \* Charformat} {IF{MERGEFIELD MyFld}< "0.66" {MERGEFIELD MyFld \* Charformat} {MERGEFIELD MyFld \* Charformat}}}
where 'MyFld' is you data field's name. I've coloured the font where you should apply text shading (via borders and shading) in the above representation, as we can't do shading, per se, here (Word can shade the text also with the same technique).

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste them from this message.

macropod
05-26-2012, 08:20 PM
Cross-posted at: http://social.msdn.microsoft.com/Forums/en-US/worddev/thread/5b3c515a-866a-4895-9bda-304f64c74ffb
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

macropod
05-26-2012, 08:36 PM
For a macro that shades the entire cell according to what it contains, see: http://www.vbaexpress.com/forum/showthread.php?t=23876&highlight=cell

Gerry22
01-14-2013, 05:26 AM
Select all the cells in your table.
Hold the shift key down on your keyboard and click the edit menu.
You will now see new menu options. Select copy picture, as seen on screen.
paste into word. This will be exactly as you see it in Excel, but as it is now a picture, you will no longer be able to edit the cells.

macropod
01-16-2013, 12:23 AM
Select all the cells in your table.
Hold the shift key down on your keyboard and click the edit menu.
You will now see new menu options. Select copy picture, as seen on screen.
paste into word. This will be exactly as you see it in Excel, but as it is now a picture, you will no longer be able to edit the cells.
That's not at all useful for what the OP is trying to achieve - which relies on a mailmerge of the Excel data.