Free Support Forum -

Change Color of text in cell at bookmark

In C# I'm using the following code to change the background color of a cell:

builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.FromArgb(r, g, b);

How do I select and change the color of ALL the text in that cell to white?

Hi Bill,

Thanks for your inquiry. Please use the following code to meet this requirement.

Document doc = new Document(MyDir + @“in.docx”);

Bookmark bookmark = doc.Range.Bookmarks["bm"];

Cell cell = (Cell)bookmark.BookmarkStart.GetAncestor(NodeType.Cell);

foreach (Run run in cell.GetChildNodes(NodeType.Run, true))

run.Font.Color = Color.Green;

doc.Save(MyDir + @"15.8.0.docx");

I hope, this helps.

Best regards,