Comments within a workbook are tracked by the Workbook.comments
property. This includes comments created by users and also comments created by your add-in. The Workbook.comments
property is a CommentCollection object that contains a collection of Comment
objects. Comments are also accessible at the Worksheet level.
To edit the comment you can use the following code:
await Excel.run(async (context) => {
// Edit the first comment in the workbook.
let comment = context.workbook.comments.getItemAt(0);
comment.content = "PLEASE add headers here.";
await context.sync();
});
To edit a comment reply, set its CommentReply.content property:
await Excel.run(async (context) => {
// Edit the first comment reply on the first comment in the workbook.
let comment = context.workbook.comments.getItemAt(0);
let reply = comment.replies.getItemAt(0);
reply.content = "Never mind";
await context.sync();
});
See Work with comments using the Excel JavaScript API for more information.