I am trying to save an Excel 2016 spreadsheet as a PDF file. I have following simple Applescript that is called from within an Objective C program:
on saveExcelAsPDF(documentPath, PDFPath)
tell application "Microsoft Excel"
open file documentPath
save active sheet in PDFPath as PDF file format
close active workbook saving no
quit
end tell
end saveExcelAsPDF
This script works great using Excel 2008 and 2011, but fails using Excel 2016 (version 15.22). Both the open and save commands fail in different ways. Can someone please help me! I have spent hours trying to get this to work. I have read all the posts on this subject that I can find. I even tried using "System Events" to mimic the keystrokes. Nothing that I have tried works. Any advice will be greatly appreciated. Thanks!!
Here's a script for Excel 2016 (version 15.22).
I've added comments in the script:
Finally I made words, powerpoints and excel works