2

I have a google doc, which I have the following script:

    var this_document = DocumentApp.openById('')
function onOpen() {
  var ui = DocumentApp.getUi();
  // Or DocumentApp or FormApp.
  ui.createMenu('SCRIPT')
      .addItem('Copy (En)', 'copy_in_english')
      .addSeparator()
      .addItem('Copy (Fr)', 'copy_in_french')
      .addSeparator()
      .addItem('Copy (Sp)', 'copy_in_spanish')
      .addSeparator()
      .addToUi();
}
function copy_in_english(){
  var cursor = this_document.getCursor()
}
function copy_in_french(){
}
function copy_in_spanish(){
}

I'm going to start with the function copy_in_english, which i want to execute when the Copy (En) menu item is pressed. From the current location of cursor, i want to copy all the text beneath it to clipboard. I saw the document.execCommand(copy) function in JavaScript which does just that, but it doesn't seem to work here. Is there anything else I could do?

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Andrew Kor
  • 579
  • 7
  • 19
  • 1
    This functionality does not exist natively in Apps Script. Best you could do is have a dialog box popup within which they could copy the translated text. – Chris Feb 23 '19 at 19:48
  • Related: https://stackoverflow.com/questions/57681314/add-content-of-showmodaldialog-to-the-clipboard-google-script – TheMaster Sep 25 '20 at 12:31

0 Answers0