使用 文件 对象或 别名 对象代替字符串。
tell application "Microsoft Excel"
activate
open file "Macintosh HD:Users:path:to:file"
-- or --> open alias "Macintosh HD:Users:path:to:file"
end tell
open POSIX file "..."
不起作用)。tell application "Microsoft Excel"
activate
set my_file to POSIX file "/Users/name/path/to/file"
open my_file
end tell
这将打开所选文件
tell application "Finder"
open selection with MicrosoftExcel
end tell
MacOS 10.14 Mojave | Excel for Mac 16.20
MacOS 10.14 Mojave | Excel for Mac 16.20
'with timeout of 10 seconds
try
-- File open may time out due to Apple's sandbox security rules.
open FileName
on error
-- A Cancel and Grant Access dialog pops up and stops execution. Click the Grant Access button.
tell application "System Events" to tell process "Microsoft Excel" to tell button "Grant Access" of window "Open" of application process "Microsoft Excel" of application "System Events" to perform action "AXPress"
end try
end timeout'
Excel 版本:16.32,Mac OS 版本:10.14.6