Word Comments, are not only used to represent readers’ opinions or reviews in contents of the document, but also be explanation of some phrases or sentences provided by author. If the contents with comments are modified or deleted, comments will be removed automatically. Or, you can select the specified comment and delete it manually if it is unnecessary any more. Now, this post will introduce an easy solution to remove Word comments in C# and Visual.
This solution is based on a .NET Word Library, Spire.Doc for .NET. So I add its dll file as reference after installing. Besides, the other thing we should prepare is a Word document with comments. The following screenshot presents contents of this document.
Firstly, we should load the document with comments by invoking LoadFrom method of Document class.
Secondly, because comments are stored in Document, so we need to get CommentCollection from Document at first, then invoke CommentCollection.RemoveAt(int index) method to remove specified comments.
Thirdly, invoke SaveToFile method of Document class to save new document without comments.
static void Main(string args)
Document document = new Document();
//Save and Launch
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim document As New Document()
‘Save and Launch
After debugging, we can find that the first comment have been removed.
The .NET Office component, Spire.Office for .NET can be used to realize this function as well.