1

I have MS Word document with table in it, all created by C#. Problem I have is how to change border color only between two cells, and not to change of whole table? Is it possible to do?

Word document is created on "usual" way, as described here.

Can you help me with this?

UPDATE: Word document and tables are created using next article: http://support.microsoft.com/kb/316384

Community
  • 1
  • 1
user198003
  • 11,029
  • 28
  • 94
  • 152
  • Rather than saying "the usual way", you should specifically name the library you used to create the document. Was it Word automation, or did you use some other library? The question you linked to lists several options, so it's not very helpful here. – phoog Jan 06 '12 at 00:48
  • ok, my message is updated, with proper link – user198003 Jan 06 '12 at 00:59
  • Please specify what exactly you are talking about - this example creates table, chart and datasheet. Color of which one do you want to change? – Kath Jan 06 '12 at 01:34

1 Answers1

4

Not sure that I selected the proper table but here is the idea:

    oTable.Cell(0, 0).Select(); //select the cell
//set up the left, right and top borders invisible (may be you don't need to do that)
            oTable.Range.Borders[WdBorderType.wdBorderLeft].LineStyle = WdLineStyle.wdLineStyleNone;
            oTable.Range.Borders[WdBorderType.wdBorderRight].LineStyle = WdLineStyle.wdLineStyleNone;
            oTable.Range.Borders[WdBorderType.wdBorderTop].LineStyle = WdLineStyle.wdLineStyleNone;

//set up the bottom border blue
            oTable.Range.Borders[WdBorderType.wdBorderBottom].LineStyle = WdLineStyle.wdLineStyleSingle;
            oTable.Range.Borders[WdBorderType.wdBorderBottom].LineWidth = WdLineWidth.wdLineWidth050pt;
            oTable.Range.Borders[WdBorderType.wdBorderBottom].Color = WdColor.wdColorBlue;

Usually if I want to do something and I don't know how to do that just open office program (Word in your case), start macro, do something, record and then see the generated code. Usually it would be enough to understand how to implement it.

Kath
  • 1,834
  • 15
  • 17