How can I use Applescript to open an Excel file in MacOs and enable the macros?
I have tried :
-- Set the path to your Excel file
set excelFile to "/Users/spagcoder/Desktop/proms webform/PROMS.xlsm"
-- Launch Excel in the background
tell application "Microsoft Excel"
activate
delay 5
open workbook workbook file name excelFile
delay 3
end tell
tell application "System Events"
tell process "Microsoft Excel"
click button "Enable Macros" of window 1
end tell
end tell
This opens the file and the but then the script just hangs when the disable/enable macros alert comes up.
If the file is already open and the macros dialog box is open, I can run a script that is just
tell application "System Events"
tell process "Microsoft Excel"
click button "Enable Macros" of window 1
end tell
end tell
And this works. The button gets clicked.