Word 文書にはいくつかのコメントがあります。強調表示した後、削除したいと思います。すべてのコメントをループできます。どのコメントが選択されているかを知る方法は? 以下のコードを書きましたが、document.Comments[i].Reference.Start
実際には存在しないようです。
MSWord.Document document = ThisDocument.Instance.InteropDocument;
try
{
DocumentProtector.Unprotect(document);
for (int i=1; i<=document.Comments.Count; i++)
{
MSWord.Range r = document.Comments[i].Reference;
if (document.Application.Selection.Range.Start == document.Comments[i].Reference.Start)
document.Comments[i].Delete();
}
}
finally
{
DocumentProtector.Protect(document);
}