我正在尝试使用AppleScript将Excel文件保存为PDF。它正常运行了2-3次,但突然开始 “错误” Microsoft Excel出现错误:参数错误。“数字-50”错误。
我不确定到底发生了什么变化。下面是我的代码:
on saveExcelAsPDF(documentPath, PDFPath)
set tFile to (POSIX path of documentPath) as POSIX file
tell application "Microsoft Excel"
set isRun to running
set wkbk1 to open workbook workbook file name tFile
alias PDFPath -- This is necessary to any script for ‘Microsoft Office 2016’, this avoid errors with any “save ... ” command
save workbook as wkbk1 filename PDFPath file format PDF file format with overwrite
close wkbk1 saving no
if not isRun then quit
end tell
end saveExcelAsPDF
saveExcelAsPDF("/Users/xyz/Documents/Excel/Book1.xlsx", "/Users/xyz/Documents/Excel/Book2.pdf")
error "Microsoft Excel got an error: Parameter error." number -50