C# 突出显示Outlook.mailItem中的特定Word.Range

C# 突出显示Outlook.mailItem中的特定Word.Range,c#,c#-4.0,outlook,vsto,outlook-2010,C#,C# 4.0,Outlook,Vsto,Outlook 2010,我还尝试从该范围中获取文本,并使用Word.Find对象和对该文本使用Find.HitHighlight方法,但问题是突出显示的文本外观超出了指定范围 任何帮助都将不胜感激 我想知道这一点,但我无法重现这一错误。对我来说,它奏效了。使用Outlook 2016。也许问题与范围的内容有关? Outlook.Inspector = Globals.ThisAddIn.Application.ActiveInspector(); Word.Document document = (Word.Docum

我还尝试从该范围中获取文本,并使用Word.Find对象和对该文本使用Find.HitHighlight方法,但问题是突出显示的文本外观超出了指定范围


任何帮助都将不胜感激

我想知道这一点,但我无法重现这一错误。对我来说,它奏效了。使用Outlook 2016。也许问题与范围的内容有关?
Outlook.Inspector = Globals.ThisAddIn.Application.ActiveInspector();
Word.Document document = (Word.Document)inspector.WordEditor;

//I have some code that determines start and end of the range i want to highlight.
//lets say they are:
object start = 0;
object end = 5;

Word.Range rng = document.Range(ref start, ref end);

//I have tried this but it didn't work but it throws an exception that Highlight 
//section is disabled or something like that.
rng.HighlightColorIndex  = WdColorIndex.wdYellow;