Skip to main content

AddComment

Adds a comment to the current run. 💡 Please note that this run must be in the document.

Syntax

expression.AddComment(sText, sAuthor, sUserId);

expression - A variable that represents a ApiRun class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sTextRequiredstringThe comment text.
sAuthorOptionalstringThe author's name.
sUserIdOptionalstringThe user ID of the comment author.

Returns

ApiComment

Example

Attach a reviewer note with an author name to a piece of text in a document.

// How do I leave a named comment on a specific section of text in a document?

// Annotate a text passage so collaborators can see feedback and who wrote it in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. Nothing special.");
paragraph.AddElement(run);
run.AddComment("comment", "John Smith");