Open file in Excel 2016 with AppleScript
In Excel 2016, the following AppleScript:
tell application "Microsoft Excel"
activate
open "Macintosh HD:Users:path:to:file"
end tell
a dialog box opens asking for access.
With previous versions of Excel, the file opens immediately. It looks like Microsoft no longer allows opening a file from a script without the user's special permission.
Is there a way to get around the dialogue?
+3
source to share
2 answers
Use file or object alias instead of string
tell application "Microsoft Excel"
activate
open file "Macintosh HD:Users:path:to:file"
-- or --> open alias "Macintosh HD:Users:path:to:file"
end tell
If you have a POSIX path you can use it ( open POSIX file "..."
doesn't work)
tell application "Microsoft Excel"
activate
set my_file to POSIX file "/Users/name/path/to/file"
open my_file
end tell
+5
source to share