I am working on a script that auto uploads .xls files into google drive from gmail and I am hitting a roadblock trying to convert the .xls file into a google sheet. The code block below was adapted from the following article: https://www.labnol.org/code/20500-convert-microsoft-excel-xlsx-to-google-spreadsheet
the variable filename is a predefined global variable
Code Snippet:
function advancedDrivetest() {
try
{
var FILE = DriveApp.getFilesByName(filename).next();
var fileID = FILE.getId();
var FILEname = "test_convert";
var blob = FILE.getBlob();
var resource = {
title: FILEname
}
Drive.Files.insert(resource, blob, {convert: true});
}
catch(f)
{
Logger.log(f.toString());
}
}
Note: I have enabled the advanced drive API in resources > Advanced drive services and in my google cloud project.
The code block above returns the rather unhelpful error mentioned in the title.
if (!GmailApp) return;
checks to see if gmail is down. – Stykesfilename
contains the.xlsx
extension in its definition (for examplevar filename = "nameOfFile.xlsx"
). – Rafa Guillermo