Can anyone tell me what the equivalent of the VBA for Selection.Find.Font.Color and Selection.Find.Replacement.Font.Color are for C#??
VBA:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Font.Color = wdColorAutomatic
Selection.Find.Replacement.Font.Color = wdColorBlue
C#:
using Microsoft.Office.Interop.Word;
using Word = Microsoft.Office.Interop.Word;
var filename = "c:\\test\\test.doc";
Word.Application wordApp = new Word.Application { Visible = false };
Word.Document doc = wordApp.Documents.Open(ref filename, ReadOnly: false, Visible: false);
Word.Find fnd = wordApp.ActiveWindow.Selection.Find;
fnd.ClearFormatting();
fnd.Replacement.ClearFormatting();
fnd.Font.ColorIndex
fnd.Forward = true;
fnd.Wrap = Word.WdFindWrap.wdFindContinue;
fnd.Format = true;
fnd.MatchCase = false;
fnd.MatchWholeWord = false;
fnd.MatchWildcards = false;
fnd.MatchSoundsLike = false;
fnd.MatchAllWordForms = false;
fnd.Font.Color?= ??? <----------------------HERE
fnd.Font.Replacement.Font.Color? = ??? <-----HERE
fnd.Text = "Find";
fnd.Replacement.Text = "Replace";
fnd.Execute(Replace: Word.WdReplace.wdReplaceAll);
In VBA it works perfectly fine but I can't figure out the C# equivalent... FYI - The first one sets the color I want to search for and the second sets the replacement text's color.