C # code to fill color in table cell in text document

I created a word document that contains a table using C #. Now I want to fill in one of the cells in this table with red color. While searching the net, I discovered that you can use a shader object for this. But I do not know how I can use it.

I tried using something like:

doc.Tables[whichTable].Cell(1,4).Range.Shading.BackgroundPatternColor 

But how can I set the color using this?

+4
source share
1 answer

If you look at this one, you will see the listed WdColor constants. These are the colors available for the word, to learn more about them, there is a listing of the listings here .

Your code to select a table cell looks correct for me, so you just need to set BackgroundPatternColor to one of WdColors.

+2
source

All Articles