Skip to content

Instantly share code, notes, and snippets.

Code to Delete Comments from Word Document in C#. For more information: https://kb.aspose.com/words/net/how-to-delete-comments-from-word-document-in-csharp/
namespace AsposeProjects
{
class Program
{
static void Main(string[] args) // Main function to remove comments from a Word file
{
// Load Words license
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense(@"Aspose.Total.lic");
// Load the input Word document
Aspose.Words.Document doc = new Aspose.Words.Document("FileWithComments.docx");
// Get all comments in the document
Aspose.Words.NodeCollection comments = doc.GetChildNodes(Aspose.Words.NodeType.Comment, true);
// Remove all comments
comments.Clear();
// Save output file
doc.Save("WithoutComment.docx");
System.Console.WriteLine("Done");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment