I am trying to create such process: You open a spreadsheet and on trigger onOpen i want to copy that spreadsheet to users drive. I do not know why code below is not doing that, i tried version with
spread = SpreadsheetApp.getActive()
but is was not also not working
function onOpen(e){
var spread = e.source
var dest = DriveApp.getRootFolder();
var name = "NEW NEW spreadsheet test"
var newfile = DriveApp.getFileById(spread.getId()).makeCopy(name,dest);
Browser.msgBox('File will appear on your Drive in a moment');
SpreadsheetApp.setActiveSpreadsheet(newfile)
}
Please i am looking to suggestions what i am missing or misinterpreting. Thank You!
onOpen(e)has limited auth-mode. Not sure you can access drive and create a spreadsheet with this authorisation. - JSmith/copyat the end rather than/edit. This way, You don't need full drive permission of every user and you respect their right to "refuse" to make a copy. - TheMaster