Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Copy a spreadsheet, rename the new one using original name
- //Display a toast message once the process has finished
- function example1() {
- var ss1 = SpreadsheetApp.getActiveSpreadsheet();
- var ss1Name = ss1.getName();
- ss1.copy(ss1Name + "-example1");
- ss1.toast("Spreadsheet copied & named", "Finished", 5);
- }
- //Add an editor and viewers to the new spreadsheet
- function example2() {
- var originalSs = SpreadsheetApp.openById('1ZI_sgQ3SGbVs4WZwYt6kuMszYFHsngLvtVbnXvvZIwQ');
- var ss2 = originalSs.copy("NEW"); //Normally don't include this line
- ss2.rename("example2");
- ss2.addEditor('brgablog2@gmail.com');
- ss2.addViewers(['brgablogse@gmail.com', 'brgablogesp@gmail.com']);
- }
- //Move a specific sheet to a new location
- function example3() {
- var currentSs = SpreadsheetApp.getActiveSpreadsheet();
- var ss3 = currentSs.copy("example3");
- var sheetAll = ss3.getSheetByName("All");
- sheetAll.activate();
- ss3.moveActiveSheet(5);
- }
- //Move a sheet to a new location using getNumSheets
- function example4() {
- var currentSs = SpreadsheetApp.getActiveSpreadsheet();
- var ss4 = currentSs.copy("example4");
- var sheetAll = ss4.getSheetByName("All");
- sheetAll.activate();
- var numOfSheets = ss4.getNumSheets();
- ss4.moveActiveSheet(numOfSheets);
- }
- //Insert a new sheet and delete a sheet
- function example5() {
- var currentSs = SpreadsheetApp.getActiveSpreadsheet();
- var ss5 = currentSs.copy("example5");
- var numOfSheets = ss5.getNumSheets();
- ss5.insertSheet(numOfSheets);
- var firstSheet = ss5.getSheets()[0];
- ss5.deleteSheet(firstSheet);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement