C# Microsoft.Office.Word.Interop删除注释
以下是我需要帮助的代码部分:C# Microsoft.Office.Word.Interop删除注释,c#,C#,以下是我需要帮助的代码部分: for (int i = 1; i <= doc2.Comments.Count; i++) { Console.WriteLine(doc2.Comments[i].Author); Console.WriteLine(doc2.Comments[i].Range.Text); Console.WriteLine("The number
for (int i = 1; i <= doc2.Comments.Count; i++)
{
Console.WriteLine(doc2.Comments[i].Author);
Console.WriteLine(doc2.Comments[i].Range.Text);
Console.WriteLine("The number of comments is: " + doc2.Comments.Count);
var regex = new System.Text.RegularExpressions.Regex("Ignore", System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Compiled);
Console.WriteLine("Regex result is " + regex.IsMatch(doc2.Comments[i].Range.Text).ToString());
Console.WriteLine("Comment Content is : '" + doc2.Comments[i].Range.Text+"'");
if (regex.IsMatch(doc2.Comments[i].Range.Text))
{
Console.WriteLine("Deleting a comment that reads - '" + doc2.Comments[i].Range.Text + "'");
doc2.Comments[i].Range.Delete();
doc2.Comments[i].Scope.Delete();
doc2.Comments[i].DeleteRecursively();
}
}
for(int i=1;i