如何更改 Word VSTO 中评论的文本背景颜色?

How to change the text background color of a Comment in Word VSTO?

我正在尝试更改 Word VSTO (2013) 中 Comment 对象的文本,但出于任何原因我无法通过 Application.ActiveDocument.Range(int,int) 或 [select 文本 comment.Reference.Find.Execute(文本)。虽然当您随后调用 .select() 方法时,这两个操作 "work" 都没有 selected。那么如何在 Word VSTO 中实现更改评论的字体或文本颜色呢?

您需要通过 Comment.Range 对象访问它,而不是 Comment.Reference。例如。

Comments[1].Range.Font.Shading.BackgroundPatternColor = WdColor.wdColorDarkTeal;

Comments[1].Range.HighlightColorIndex = WdColorIndex.wdYellow;