Last active
July 23, 2022 05:03
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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