mountainman88
Board Regular
- Joined
- Jun 22, 2019
- Messages
- 109
- Office Version
- 2016
- Platform
- Windows
I have this google apps script which converts an excel file to a google sheets file in the same folder based on the file name in cell a1 on a tab called files:
main(){ let spreadsheet = SpreadsheetApp.getActive(); let sheet = spreadsheet.getSheetByName("files"); let fileName = sheet.getRange("A1").getValue(); let spreadsheetId = convertExcelToGoogleSheets(fileName); importDataFromSpreadsheet(spreadsheetId); } function convertExcelToGoogleSheets(fileName) { let files = DriveApp.getFilesByName(fileName); let excelFile = null; if(files.hasNext()) excelFile = files.next(); else return null; let blob = excelFile.getBlob(); let config = { title: "[Google Sheets] " + excelFile.getName(), parents: [{id: excelFile.getParents().next().getId()}], mimeType: MimeType.GOOGLE_SHEETS }; let spreadsheet = Drive.Files.insert(config, blob); return spreadsheet.id; }
How can I change this script so cell A1 and B1 are input and output folder urls. I would like the script to scan the A1 folder link and convert all excel files within it to Google Sheets and then output or the B1 folder url.
Thanks
main(){ let spreadsheet = SpreadsheetApp.getActive(); let sheet = spreadsheet.getSheetByName("files"); let fileName = sheet.getRange("A1").getValue(); let spreadsheetId = convertExcelToGoogleSheets(fileName); importDataFromSpreadsheet(spreadsheetId); } function convertExcelToGoogleSheets(fileName) { let files = DriveApp.getFilesByName(fileName); let excelFile = null; if(files.hasNext()) excelFile = files.next(); else return null; let blob = excelFile.getBlob(); let config = { title: "[Google Sheets] " + excelFile.getName(), parents: [{id: excelFile.getParents().next().getId()}], mimeType: MimeType.GOOGLE_SHEETS }; let spreadsheet = Drive.Files.insert(config, blob); return spreadsheet.id; }
How can I change this script so cell A1 and B1 are input and output folder urls. I would like the script to scan the A1 folder link and convert all excel files within it to Google Sheets and then output or the B1 folder url.
Thanks