How to Reply to a Comment in Word in C#, VB.NET

In Word 2013 and later version, you can reply to a comment, so it's easier to follow the whole conversation. Spire.Doc also allows programmers to insert a comment as a reply to a selected comment through ReplyToComment method.

Step 1: Create an object of Document and load a Word document containing comments.

Document doc = new Document();
doc.LoadFromFile("Comment.docx");

Step 2: Get the first comment.

Comment comment = doc.Comments[0];

Step 3: Create a new comment and specify the author and content.

Comment replyComment = new Comment(doc);
replyComment.Format.Author = "Adam";
replyComment.Body.AddParagraph().AppendText("Exactly.");

Step 4: Add the new comment as a reply to the selected comment.

comment.ReplyToComment(replyComment);

Step 5: Save to file.

doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013);

How to Reply to a Comment in Word in C#, VB.NET

Full Code:

[C#]
Document doc = new Document();
doc.LoadFromFile("Comment.docx");
Comment comment = doc.Comments[0];

Comment replyComment = new Comment(doc);
replyComment.Format.Author = "Adam";
replyComment.Body.AddParagraph().AppendText("Exactly.");
comment.ReplyToComment(replyComment);

doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013);
[VB.NET]
Dim doc As New Document()
doc.LoadFromFile("Comment.docx")
Dim comment As Comment = doc.Comments(0)

Dim replyComment As New Comment(doc)
replyComment.Format.Author = "Adam"
replyComment.Body.AddParagraph().AppendText("Exactly.")
comment.ReplyToComment(replyComment)

doc.SaveToFile("ReplyToComment.docx", FileFormat.Docx2013)