Here is a screenshot of the relevant Excel Library
Here is a screenshot of the error
Here is my code:
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
When I try to compile I get an error alert which says "Syntax Error; Expected end of line, etc. but found identifier" and the second "workbook" word is highlighted on line 6. What am I doing wrong?
Thanks!
I figured it out! When I used the line 'tell application "Microsoft Excel"', it was referring to the Windows version of Excel (running via parallels desktop), instead of Excel for Mac. I replaced that line with 'tell application "/Applications/Microsoft Excel.app"' and it compiles perfectly now.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.