2016-09-21 32 views
0

Here is a screenshot of the relevant Excel LibraryAppleScript的语法错误使用Excel时,“打开的工作簿”命令

Here is a screenshot of the error

这里是我的代码:

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 
     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 

当我尝试编译我得到一个错误警报它说“语法错误;预计行结束等,但找到标识符“,第二行”工作簿“字在第6行突出显示。我在做什么错了?

谢谢!

回答

0

我想通了!当我使用'告诉应用程序'行'Microsoft Excel''时,它指的是Windows版本的Excel(通过parallels桌面运行),而不是Mac版的Excel。我用“告诉应用程序”/ Applications/Microsoft Excel.app“替换了这行,现在它编译完美。

相关问题