How do you extract comments from an MS Word doc that's been imported into Google Docs and put in a Google Sheet?

Viewed 21

How do you extract comments from an MS Word doc that's been imported into Google Docs and put in a Google Sheet?

I've followed this suggestion to get REALLY close, including adding my own line for another column that shows WHO left the comment.

I am suspecting that MS Word native files that are imported into GDocs use some other convention for comments because there's a footer for those comments that says, "From Imported Document".

If this is true, then is there a solution for Word>GDocs imported documents with comments?

Here's my code but w/o my docID:

function listComments() {
  // Change docId into your document's ID
  // See below on how to
  var docId = ''; 
  var comments = Drive.Comments.list(docId);
  var hList = [], cList = [], nList = [];

  // Get list of comments
  if (comments.items && comments.items.length > 0) {
    for (var i = 0; i < comments.items.length; i++) {
      var comment = comments.items[i]; 
      // add comment and highlight to array's first element 
      hList.unshift([comment.context.value]);
      cList.unshift([comment.content]);
      nList.unshift([comment.author.displayName]);
    }
    // Set values to A and B
    var sheet = SpreadsheetApp.getActiveSheet();
    sheet.getRange("A1:A" + nList.length).setValues(nList);
    sheet.getRange("B1:B" + hList.length).setValues(hList);
    sheet.getRange("C1:C" + cList.length).setValues(cList);

  }
}
0 Answers
Related