Pierre Lemoine
Pierre Lemoine

Reputation: 61

Access Google docs comments from Google app scripts

I am writing google docs with several people at the same time and in order to track who has to do what, I am using comments.

Each part of the document is then assigned to someone and he has to update the status of his part in the comment (in a structured format).

Thanks to a Macro in VBA, I extract this and put the results in a spreadsheet.
It's then easy to track the status of the document.

It's something easy to do in MS Word but not in Google docs. I can't find any way to access the comments from a google app script.

Do you know if such way exist?

Something like Document.getBody().getComments().

If you have any solution, I would be happy to know as I can't anything on the net.

Upvotes: 2

Views: 5088

Answers (1)

Pierre Lemoine
Pierre Lemoine

Reputation: 61

Thanks. I found something in the API in the meantime.

function listComments() {
  var comments = Drive.Comments.list(DocumentApp.getActiveDocument().getId());

  if (comments.items && comments.items.length > 0) {
    for (var i = 0; i < comments.items.length; i++) {
      var comment = comments.items[i];  
      Logger.log('Comment : %s', comment.toLocalString());
    }
  } else {
    Logger.log('No comment found.');
  }
}

Upvotes: 4

Related Questions