I want to make the text color of the x sign red. I have tried this oWord.Selection.Font.ColorIndex = Word.WdColorIndex.wdRed; but it didn't work.
if (fieldName == "K")
{
myMergeField.Select();
oWord.Selection.TypeText("X"); // I want to make the x sign red
oWord.Selection.Font.ColorIndex = Word.WdColorIndex.wdRed;
}

Jayraj ChhayaRank #304 · 8.2K reputationPosted Feb 16, 2024, 6:22 AM EST
To change the text color in Word automation using C#, you can use the
Font.Colorproperty instead ofFont.ColorIndex. TheColorproperty allows you to specify the color directly, while theColorIndexthe property uses predefined color indexes.Here's an updated version of the code that should work:
if (fieldName == "K") { myMergeField.Select(); oWord.Selection.TypeText("X"); // I want to make the "X" sign red oWord.Selection.Font.Color = Word.WdColor.wdColorRed; }kishanvaghela34 reputationPosted Feb 16, 2024, 7:07 AM EST
using Word = Microsoft.Office.Interop.Word; if (fieldName == "K") { myMergeField.Select(); oWord.Selection.TypeText("X"); oWord.Selection.Font.Color = Microsoft.Office.Interop.Word.WdColor.wdColorRed; }Mehmet FatihRank #1,475 · 1.1K reputationPosted Feb 16, 2024, 1:29 PM EST
Thanks both of you. They worked for me.