Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

how to run Excel 2011 from applescript for batch

Every night at 2:00am, I want to convert an Excel spreadsheet to CSV. I'm doing this on a Mac, with Excel 2011. The following Applescript works sometimes:


tell application "Microsoft Excel"

open "/Users/siemsen/PetesLookup/BPO.inventory.current.xls"

save active workbook in "BPO.inventory.current.csv" as CSV file format


closeworkbook 1 savingno


quit

end tell


With the above script saved in a file named convert.scpt, I can execute it from a bash script using the command "osascript convert.scpt". The bash script runs in a launchd job at 2:00am every day.


It works if Excel is already running on the Mac at the time the cron job runs. If not, it starts Excel, which insists on displaynig a "Excel Workbook Gallery" dialog box. No one is present on the Mac at the time, so no one clicks on the "Cancel" in the dialog box, so the Applescript times out and the cron job fails.


How do I get around this? Can I somehow start Excel without the **** "Excel Workbook Gallery" dialog? Is there some other trick that will allow the job to run unattended?

MacBook Pro, Mac OS X (10.6.7)

Posted on Dec 5, 2012 8:15 AM

Reply
Question marked as Best reply

Posted on Dec 5, 2012 8:25 AM

In Excel preferences (general tab) uncheck the checkbox that says "Open Project Gallery when application opens". that should remove the startup dialog.

2 replies

how to run Excel 2011 from applescript for batch

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.