-1

The problem I'm interested to know if it is possible to copy the entire contents of one Google Doc and paste into a comment in another Google Docs using keyboard commands.

Background- I do a lot of grading of student papers and have a range of standard comments I use which are individually stored in separate documents. I use Macros and keyboard shortcuts in MS Word to grab the contents of the comment file I want and put it into a comment in the paper I'm grading. I edit the macro files using the VB editor when necessary. It works quite efficiently.

I found some related material in my research, however this don't quite match what I am trying to do.

I think the code from here Insert comment into Google doc does something like what I want, but kind of the opposite.

Google Apps Scripts is new to me. I'm not really looking to become a programmer, I just need to know if developing such a script is possible or not and how hard it would be. I would appreciate being pointed in the right direction. Thanks.

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Derin
  • 11
  • 1
  • 1
  • I just inserted the contents of one of my documents into a comment in another document. So I guess the answer is yes. Actually you do have to use a mouse click to complete the comment – Cooper Aug 25 '19 at 00:45
  • Hi Cooper. I guess what I am interested in is setting up a Google App Scrip that does the same as the macro I use in MS word. I trigger the macro with keyboard commands. A dialogue box opens and then with one mouse click I can choose the file I want to import into the comment in the document I'm editing. I don't have to open the source (comment) document, the macro "imports" the text into the comment in the document I'm editing. I hope this makes sense. – Derin Aug 25 '19 at 09:00

1 Answers1

0

A sample to point you into the right direction:

function myFuction()
{
  var fileOriginId='PASTE HERE THE ID OF THE FILE WITH THE COMMENT TEXT';
  var fileDestinationId ='PASTE HERE THE ID OF THE FILE WHERE THE COMMENTS SHALL BE INSERTED';
  var text=DocumentApp.openById(fileOriginId).getBody().getText()
  var comment={ 'content': text};
  Drive.Comments.insert(comment, fileDestinationId);
}

enter image description here

This code snippet passes the whole contents of a Google Docs document to the variable text. Subsequently, the contents of text is inserted as a comment into a second Google Docs document. It uses the Advanced Drive Service that needs to be enabled beforehand.

  • Should you desire to pass only a part of the text in the original file into the comment, e.g. a paragraph, you would need to chose the specific paragraph instead of the whole document body.
  • Should you desire to append the comment to a certain text within the destination document, you need to use the optional property context.value, as done in the reference you provided.

Please find here references to useful documentation that will help you udderstand Apps Script and adjust the code snippet provided to your requirements:

ziganotschka
  • 25,866
  • 2
  • 16
  • 33