I spent many fruitless hours Googling for a working example of AppleScript code to Open a CSV file and to do a Save As a .xlsx file in Excel 2016 (v16.14.1), and I was wondering if anyone had any advice or suggestions.
I can’t get the “open text file” AppleScript command to work in Excel unless the text file had been previously opened by Excel manually. I hacked my way around my inability to open the csv file under AppleScript by issuing:
open -A “Microsoft Excel” ~/Downloads/2018-06-26_test.csv
from within a bash script, which did open it in Excel, but that’s just skating around the problem.
Unsurprisingly, just like I couldn’t open a CSV file from within AppleScript, I can’t save an .xlsx file either.
All variants of:
save workbook as workbook theWorkBookName filename theLogFileName file format Excel98to2004 file format with overwrite
fail miserably. I suspect that I am running into Sandboxing issues. I keep getting Invalid Object References, "Microsoft Excel got an error: The object you are trying to access does not exist” or parameter errors.
As an aside, when I right-click on the title of the CSV document from the ~/Downloads directory that I manually opened in Excel, the following path is exposed:
All I’ve got is a dated 2004 Excel AppleScript reference, and I’m getting nowhere fast. I’d be grateful for any guidance.