0

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);

  }
}
  • 1
    Welcome to [so]. It's not clear what is being asked. Have you tried the code included in the question? If it's not working add the relevant execution logs, i.e. the textual error message if there is any. Is there is something that is missing in your code? – Rubén Sep 23 '22 at 15:38
  • Hi, @Rubén and thanks for writing back! I know it's a confusing sequence and I'm new to asking for such help here! My edited script works perfectly to extract comments from documents CREATED in Google Docs. But it fails for extracting comments from MS Word documents IMPORTED into Google Docs. Perhaps there's a different "var" in Google's "Drive API" I should use for docs that were imported. Or perhaps, calling those comments just not supported at all because imported MS Word comments are actually an altogether different "object" in their schema than comments that were made in GDocs – Eric Nentrup Sep 23 '22 at 20:40
  • Thanks for your reply Eric. Are you able to see the comments on the converted document? P.S. Please [edit] the question to add to it all the relevant details in an organic way, try to make your question easier to understand for someone that read it for first time. Please avoid to append clarifications at the end. – Rubén Sep 23 '22 at 20:46
  • 1
    About `My edited script works perfectly to extract comments from documents CREATED in Google Docs. But it fails for extracting comments from MS Word documents IMPORTED into Google Docs.`, in this case, can you provide the sample DOCX file and provide your expected values? By this, I would like to confirm your current situation. – Tanaike Sep 24 '22 at 00:30
  • Unfortunately I can't share the document but I can clarify that you are able to SEE the MS Word-originated comments that are imported into GDocs, but those comments in the margin are tagged with a footer that says that it's imported. Comments in a native GDocs do NOT have this footer. I suspect there's another name for these comments but don't know if it's available in the public API documentation, given how elusive this request seems here. – Eric Nentrup Sep 26 '22 at 15:15

0 Answers0