saving a sheet to a different folder

57 views
Skip to first unread message

Adam Smith

unread,
May 18, 2022, 4:13:44 PM5/18/22
to Google Apps Script Community
I am working on a script to save a template sheets file in a different folder within the same directory as the template. I have searched up and down trying to make this work and I just dont understand what I am missing. Here are a few of the things I have tried:

function myFunction() {
  // Log the name of every file in the user's Drive.
// This code makes a copy of the current spreadsheet and names it appropriately
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.copy("Copy of " + ss.getName());
//var ss2 ="Copy of " + ss.getName()
//var folder = "Awaiting Professor Approval"
//ss2.makeCopy("new name", folder);

//file.moveTo("Awaiting Professor Approval");
}

Martin Molloy

unread,
May 18, 2022, 6:47:10 PM5/18/22
to google-apps-sc...@googlegroups.com
This works

function fileFromTemplate(){
var templateID = '1_TObQh5jvsOvp5O_lehmRvHn0SSbN85EO-yolskm23I'  //replace with your TemplateFileID
var templateFile = DriveApp.getFileById(templateID//gets the template file
var folderID = '1vdqoL4MDs3l5OM10vLPUJG3jRJ2HaitA'  //Replace with the id of your destination folder
var folder = DriveApp.getFolderById(folderID)  
var name = "Whatever you want the name of the new file to be"
templateFile.makeCopy(namefolder//Makes the copy in the destination folder
}




--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/85038807-3db4-435c-9896-d692863722c1n%40googlegroups.com.

Adam Smith

unread,
May 19, 2022, 10:03:42 AM5/19/22
to Google Apps Script Community
thank you so much!!
Reply all
Reply to author
Forward
0 new messages