How to Insert Comment into Word Document using C#

In this topic, we will explain how to insert comment into word document using C#. The comment annotation in MS Word is anchored to a position in text or a region of text. In Aspose.Words’ document object model the comment is an inline-level node and can only be a child of Paragraph. We will use sample input Word document and insert a comment at the start of DOCX with few lines of C# code. You can use the same approach to insert the comment to any paragraph in document.

Steps to Insert Comment into Word Document using C#

  1. Install Aspose.Words for .NET package from
  2. Add reference to Aspose.Words
  3. Set license using License.SetLicense method before importing Document
  4. Import the input Word document
  5. Initialize instance of DocumentBuilder class and move the cursor to the beginning of the document
  6. Initialize instance of the Comment class and add comment’s text using Paragraph
  7. Add comment to first paragraph of document
  8. Finally, save the document to Word DOCX file format

Previously, we looked into How to Convert PDF to Word in C# Without Interop. Now, you will learn how to insert comment into DOCX file format.

Code to Insert Comment into Word Document using C#

Inserting comment into Word document using above C# code does not need to install MS Office and can be used where .NET is installed. This code example inserts the comment at the end of first paragraph of document.