I want to schedule an Excel macro to run every week on MacOS. I am using Applescript but when I run the script, it seems to open the file but the macro doesn't run. Also, how do I automatically enable macros when the Excel file is opened?
This is the script :
-- Set the path to your Excel file
set excelFile to "/Users/spagcoder/Desktop/proms webform/PROMS.xlsm"
-- Set the name of the macro to run
set macroName to "findRecipients"
-- Launch Excel in the background
tell application "Microsoft Excel"
activate
open workbook workbook file name excelFile
tell workbook 1
run VB macro macroName
end tell
-- Optionally save and close the workbook
save workbook 1
close workbook 1 saving yes
-- Optionally quit Excel
quit
end tell