Script fails on time-driven trigger?

77 views
Skip to first unread message

Marco Nieuwenhuis

unread,
Mar 28, 2019, 5:53:40 PM3/28/19
to Google Apps Script Community
Hi Experts,

I have a script to convert Excel file to Google Spreadsheet. When I execute the script from within the script editor it works perfectly fine but when I set a time-driven trigger it fails over and over with the error below.

The following object could not be retrieved: the iterator has reached the end. at convertExceltoGoogleSpreadsheet (Excel_Convert: 4)

Does this have something to do with rights perhaps? Below the script I'm using. 

Hope someone can help me out on this. Thanks in advance!

Regards,
Marco

var dstFileId = '1PUXjW0fxR66...........'; // file Id of Existing Spreadsheet
function convertExceltoGoogleSpreadsheet(fileName) {
fileName = fileName || "test_ds.xlsx"; //  excel_file_name.xlsx = name of specific Excel file
var excelFile = DriveApp.getFilesByName(fileName).next();
var fileId = excelFile.getId();
var srcFileId = fileId; // file Id of Excel file
Drive.Files.update({}, dstFileId, DriveApp.getFileById(srcFileId))};

Kanshi Tanaike

unread,
Mar 28, 2019, 7:21:00 PM3/28/19
to Google Apps Script Community
I think that the error message indicates that the file with "fileName" is not found. How about confirming the filename sent to "convertExceltoGoogleSpreadsheet(fileName)" again?

Reply all
Reply to author
Forward
0 new messages