使用以下代码可以突出显示搜索文本。但是,如果搜索文本是“也”,那么“也”不会突出显示。如何忽略案例。
foreach (Word.Range w in doc.Words)
{
for (int i = 1; i < xmlnode.Count; i++)
{
XmlAttributeCollection xmlattrc = xmlnode[i].Attributes;
object text = xmlnode[i].FirstChild.InnerText;
if (w.Text.Trim() == text.ToString())
{
w.Font.Bold = 1;
w.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkYellow;
}
}
}
}