I have a model of spreadsheet, and I want to automatically duplicate the sheet in this model to a new spreadsheet (not in the same spreadsheet). This new spreadsheet must be automatically opened and saved in my Google Drive. How can I do this?
I started with this code but it doesn't work
function CreateReports()
{
var ssNew = SpreadsheetApp.create(date);
var url = ssNew.getUrl()
var ss = SpreadsheetApp.openByUrl(url);
Logger.log(ssNew.getUrl());
}
If you want to duplicate the entire spreadsheet, see the example in the documentation for
Spreadsheet.copy()
.This script will:
code
If the script is running as the end user (which it does automatically from the Script Editor), the any create or copy of a spreadsheet ends up in the Drive without any additional steps.
Its not possible to automatically open a Spreadsheet or any window for that matter. The user will have to click on the URL after the create/copy is made.
So in order to the spreadsheet UI, you have to show the URL from
getUrl
in a popup or email it to the user and they can click in.