0

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);
}
4

1 に答える 1

1

使用Range.InRange方法:

メソッドが適用される範囲が Range 引数で指定された範囲に含まれる場合、True を返します。

于 2012-07-07T10:31:12.067 に答える