在MS WORD VSTO中,您可以按以下方式查找/替换文本颜色。我们可以在new Office WORD-AddIn platform中为MS WORD实现相同的目标吗?我正在使用Office 2016。
public bool ReplaceFont(Word.Range rng, string findWhat)
{
bool hasFound = false;
rng.Find.ClearFormatting();
rng.Find.Replacement.ClearFormatting();
rng.Find.Replacement.Font.ColorIndex = Word.WdColorIndex.wdBlue;
rng.Find.Text = findWhat;
rng.Find.Replacement.Text = findWhat;
rng.Find.Forward = true;
rng.Find.Wrap = Word.WdFindWrap.wdFindStop;
//change this property to true as we want to replace format
rng.Find.Format = true;
hasFound = rng.Find.Execute(Replace: Word.WdReplace.wdReplaceAll);
return hasFound;
}