I'm a language teacher, and I often share documents with students and ask them to highlight new words. During the classes, I often make comments with the definitions of the words and other info.
I thought it would be way more efficient if I found some way to extract the highlights and comments directly into Google Sheets (I want the students to be able to easily make flashcards using Anki).
I found another StackOverflow post about a way to write a script to do this, but I can't seem to get it to work. Here's the message I get when trying to run it:
function listComments() {
// Change docId into your document's ID
// See below on how to
var docId = 'doccode';
var comments = Drive.Comments.list(docId);
var hList = [], cList = [];
// 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]);
}
// Set values to A and B
var sheet = SpreadsheetApp.getActiveSpreadsheet();
sheet.getRange("A1:A" + hList.length).setValues(hList);
sheet.getRange("B1:B" + cList.length).setValues(cList);
}
}
There's a TypeError with the "getRange" property, and I'm not sure what to change. (Sorry, almost completely new to coding, so it's probably an obvious answer!)
Any help is appreciated!