Problem adding Comments to a Word document

Hello,

I’m trying to insert new comments into a Word document using Aspose.Words version 8.0. I can successfully add new comments with comment text in the desired place by inserting the Comment node after the text run. The problem is, I don’t see anywhere in the object model where I can specify how much of the text run the comment should span in the original text. When adding a new comment, the comment span is 0 length (shows up as just a sliver).

Any advice on this would be very helpful.

Thanks,

Scott

This message was posted using Page2Forum from How-to: Extract or Remove Comments - Aspose.Words for .NET and Java

Hi Scott,

Thanks for your request. Unfortunately, there is no way to comment the arbitrary range in the document. Your request has been linked to the appropriate issue. You will be notified as soon as this feature is supported.

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!!!"));
comment.AppendChild(commentParagraph);
// 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.
builder.InsertNode(comment);
builder.InsertNode(start);
// Insert some more text.
builder.Write("This is commented text ");
// Insert end of comment range.
builder.InsertNode(end);
// And finaly insert some more text.
builder.Write("This is text aftr comment");
// Save output document.
doc.Save(@"Test001\out.doc");

Best regards,