GetCommentById

GetCommentById(sId) → { ApiComment }

Returns a comment from the current document by its ID.

Parameters:

Name Type Description
sId string

The comment ID.

Returns:

Type
ApiComment

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is just a sample text");
Api.AddComment(oParagraph, "comment", "John Smith");
var aComments = oDocument.GetAllComments();
var sId = aComments[0].GetId();
var oComment = oDocument.GetCommentById(sId);
var sAuthor = oComment.GetAuthorName();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Comment author name: " + sAuthor);
oDocument.Push(oParagraph);
builder.SaveFile("docx", "GetCommentById.docx");
builder.CloseFile();

Resulting document