I've scoured the interweb and found many many "solutions" to this problem, none of which seem to work for me.
My problem is a simple one. I want to import information from a changeable source file .... I think I have this licked once I get over the actual problem of opening the external spreadsheet in the first place.
I'm using Google Apps Script and am trying to open a file within the same Google Drive, from a separate GoogleDoc-spreadsheet.
The following code as far as I can see (once you take out the comments) should open a spreadsheet file but gives an illegal key error.
function openafile() {
var files = DriveApp.getFiles();
while (files.hasNext()) {
var file = files.next();
// =//= look for a specific type of spreadsheet file (excel) - this will always be exported as this Mime Type
if ( file.getMimeType() == 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ) {
Logger.log('Attempting to open ' + file.getName());
// =//= none of these seem to work .... why?
// var ss = SpreadsheetApp.openById(file.getId());
// var ss = SpreadsheetApp.open(file);
// var ss = SpreadsheetApp.openByUrl(file.getUrl());
Logger.log('Success: ' + ss.getName());
}
}
}