2012-03-01 56 views
1

有人能告訴我什麼是錯的下面的AppleScript的AppleScript不會打開的Excel 2011工作簿

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 

腳本作品,如果我硬代碼個人文件路徑,所以問題必須在設置sourceFile行,但我需要能夠選擇一個文件,因爲它不總是相同的。

回答

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

這工作。原因是'choose file'函數返回一個* alias *,而Excel期望文本形式的文件路徑 – fanaugen 2012-03-01 13:33:19

相關問題