Applescript不会打开Excel 2011工作簿

时间:2012-03-01 12:23:30

标签: excel applescript applescript-excel

有人可以告诉我下面的AppleScript有什么问题吗

set sourceFile to (choose file with prompt "Choose source files" of type {"XLS6", "XLS7", "XLS8", "XLS", "TXT"} with multiple selections allowed without invisibles)
tell application "Microsoft Excel"
-- activate
open workbook workbook file name sourceFile
end tell

我收到以下错误

error "Microsoft Excel got an error: Can’t continue open workbook." number -1708

如果我对单个文件路径进行硬编码,则该脚本有效,因此问题必须在set sourceFile行中,但我需要能够选择一个文件,因为它并不总是相同。

1 个答案:

答案 0 :(得分:3)

试试这个:

set sourceFile to (choose file with prompt "Choose source files" of type {"XLS6", "XLS7", "XLS8", "XLS", "TXT"} with multiple selections allowed without invisibles) as string
tell application "Microsoft Excel"
open sourceFile
end tell