Reputation: 3
I have way to much code to paste in, so I created the simplest version of my problem. I get the error "Cannot find method (class)addFile($Proxy1084). (line 96, file "Macros")" For the record, line 96 is the folder.addFile(copySS). It creates the sheet. Logger data will give me the name of the folder. If anyone has any clue why this isn't rolling I could use the assist.
function test2(){
var folders = DriveApp.getFolders();
var file = "Testy McFile";
while(folders.hasNext()){
var folder = folders.next();
// find all the NFL folders
if(folder.getName() === 'NFL'){
var copySS = SpreadsheetApp.create(file);
Logger.log(folder.getName());
folder.addFile(copySS);
//this is test code so in case it works... don't make a dozen copies
break;
}
}
}
Upvotes: 0
Views: 2860
Reputation: 3732
copySS here is an Spreadsheet object, not file Object. However addFile
method expects a file object from Drive app. That is why you are getting this error.
Here is modified code which works fine.
function test2(){
var folders = DriveApp.getFolders();
var file = "Testy McFile";
while(folders.hasNext()){
var folder = folders.next();
// find all the NFL folders
if(folder.getName() === 'Imp'){
var fileId = SpreadsheetApp.create(file).getId();
var file = DriveApp.getFileById(fileId);
Logger.log(folder.getName());
folder.addFile(file);
break;
}
}
}
Upvotes: 4