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 ChhayaPosted Feb 16, 2024, 11:22 AM
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:
Mehmet FatihPosted Feb 16, 2024, 6:29 PM
Thanks both of you. They worked for me.
kishanvaghelaPosted Feb 16, 2024, 12:07 PM