Reputation: 83
I get the error message: "Specified sheet must be part of the spreadsheet". I assume the "specified sheet" is the sourceSheet... but who knows. What is this trying to tell me? Better yet, how do I fix it? I want to insert a sheet from spreadsheet "File1", into spreadsheet "File2".
Thank you
function copyTemplate() {
var targetID="0Atn-Fxxxxt5YdF9VVxxxxxxxlZlVmeXoxxxzJuQ3c";
// The code below will duplicate the sheet named "CellData" and insert it after
// the 1st sheet and call it "CellData"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sourceSheet = ss.getSheetByName("CellData");
var targetFile=SpreadsheetApp.openById(targetID);
targetFile.insertSheet("CellData", 1, {template:sourceSheet});
}
Upvotes: 0
Views: 841
Reputation: 5051
function copyTemplate() {
SpreadsheetApp.getActiveSpreadsheet().getSheetByName('CellData')
.copyTo(SpreadsheetApp.openById('0Atn-Fxxxxt5YdF9VVxxxxxxxlZlVmeXoxxxzJuQ3c'));
}
Upvotes: 1