We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to insert comments to the document


How can I insert comments to the document using Aspose.word. Is it possible? Does this support have in Aspose?

Thanks for your assistance.

With Aspose.Words you can add comments using code like this:

Comment comment = new Comment(doc);
comment.Paragraphs.Add(new Paragraph(doc));
comment.FirstParagraph.Runs.Add(new Run(doc, “Some coment.”));

Unlike MS Word comments in Aspose.Words can be bound only to paragraph end marks rather than arbitrary range in the document. That is a temporary limitation which will be corrected in the future versions.

Has this been corrected, and able to bound comment to the arbitrary
range in the doc? This ability is one of the keys to our application.

Thank you


Not yet. We are a bit overwhelmed with implementing lots of major features right now. I am afraid we won’t be able to deal with it for another 2-3 months. Sorry for delay. We will most probably support this in the next year.
Best regards,


Is this possible to replace commented document range with new content?

I don’t want to change the comments text, I want to change the commented document range with some other content.

Please provide a code snippet .

Waiting for your quick reply


Thanks for your inquiry. Unfortunately commented ranges are not supported by Aspose.Words yet. This is issue #1012 in our defect database.
Best regards.

We are happy to notify you that the latest version of Aspose.Words supports commented ranges. You can download the latest version fo Aspose.Words from here..
Here is a simple code example, which allows insertion commented range into the document:

// Create an empty document and DocumentBuilder object.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Create a Comment.
Comment comment = new Comment(doc);
// Insert some text into the comment.
Paragraph commentParagraph = new Paragraph(doc);
commentParagraph.AppendChild(new Run(doc, "This is comment!!!"));
// Create CommentRangeStart and CommentRangeEnd.
int commentId = 0;
CommentRangeStart start = new CommentRangeStart(doc, commentId);
CommentRangeEnd end = new CommentRangeEnd(doc, commentId);
// Insert some text into the document.
builder.Write("This is text before comment ");
// Insert comment and comment range start.
// Insert some more text.
builder.Write("This is commented text ");
// Insert end of comment range.
// And finaly insert some more text.
builder.Write("This is text aftr comment");
// Save output document.

Best regards,