1

I've developed a VSTO Outlook add-in that uses the track changes comment functionality of Word to highlight certain keywords in emails. This works great in Outlook 2010, but not in Outlook 2013. When I attempt to do this, I get the following exception:

System.Runtime.InteropServices.COMException (0x800A11FD): This command is not available.
    at Microsoft.Office.Interop.Word.Comments.Add(Range Range, Object& Text)

This seems to imply that the function is not available, even when using Word as the Outlook message editor. I checked this by verifying the registry key HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Options\Mail value EditorPreference is set to 0x00030001 (196609), which should set Word as the editor.

I know that Microsoft changed how comments work in Office 2013, but the functionality is fundamentally the same from the user perspective.

Does anyone have insight into why this could be happening, or more importantly a fix or workaround?

My code is below:

var document = Inspector.WordEditor as Word.Document;
foreach (Word.Paragraph paragraph in document.Paragraphs) {
    range = paragraph.Range;
    range.Collapse(Word.WdCollapseDirection.wdCollapseStart);
    range.MoveStart(Word.WdUnits.wdCharacter, highlight.Start);
    range.MoveEnd(Word.WdUnits.wdCharacter, highlight.Length);
    var comment = range.Comments.Add(range, "Look at this word!");
}
4

0 回答 0