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?