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

Free Support Forum - aspose.com

Java Code to Add Remove Reply Comments to/from Word Document | Export or Read Comments along with Replies

Dear all,

I have a comment with a reply for it. The document is exported with the comment and its reply.I was able to export the comment.

I wanted to display the following comment with reply.

John :This is Comment
Jeff : Replied for the comment

// Below code exports the first level comment

Comment comment = new Comment(doc);

Paragraph commentParagraph = new Paragraph(doc);
commentParagraph.appendChild(new Run(doc, “This is Comment.”));
CommentRangeStart start = new CommentRangeStart(doc, comment.getId());
CommentRangeEnd end = new CommentRangeEnd(doc, comment.getId());
builder.write(“This Element Has Comment”);

but I also want to export its reply, left indent with reply icon disabled . Does Aspose.Word support that?
Hi there,

Thanks for your inquiry. Currently, you can not set "reply comment" to a comment using Aspose.Words. Your request has been linked to the appropriate issue (WORDSNET-9959) and you will be notified as soon as it is supported.

We apologize for your inconvenience.


The issues you have found earlier (filed as WORDSNET-9959) have been fixed in this Aspose.Words for .NET 17.10 update and this Aspose.Words for Java 17.10 update.


Please note that we had also added following new public methods in Comment class during integrating the fix of WORDSNET-9959 in 17.10 version of Aspose.Words for Java API:

  • addReply: Adds a reply to this comment. Due to the existing MS Office limitations only 1 level of replies is allowed in the document. An exception of type System.InvalidOperationException will be raised if this method is called on the existing Reply comment.
  • removeReply: Removes the specified reply to this comment. All constituent nodes of the reply will be deleted from the Word document.
  • removeAllReplies: Removes all replies to this comment. Again, all constituent nodes of the replies will be deleted from the Word document

The following Java code of Aspose.Words API will first remove a reply from comment and then add a new reply to a comment in Word document:

Document doc = new Document("C:\\Temp\\Comments.docx");
Comment comment = (Comment)doc.getChild(NodeType.COMMENT, 0, true);


comment.addReply("John Doe", "JD", new Date(2017, 9, 25, 12, 15, 0), "New reply");


To learn more about comments, please refer to the following article: