I am trying to open a password protected Microsoft Excel file using AppleScript.
I have written two different AppleScripts and both “fail” when trying to enter the workbook password.
The first script is as follows:
tell application "Microsoft Excel"
activate
set TheFileToOpen to "/Users/JoelC/Documents/Projects On The Go/Budget and Spend Tracking/20140101_budget and expenditure.xlsx"
set TheWorkBook to "20140101_budget and expenditure.xlsx"
set TheWorksheet to "Budget_2021"
set ThePassword to "abcdefgh"
open TheFileToOpen
tell application "System Events" in window "Password" of "Microsoft Excel" to keystroke ThePassword
end tell
The second script is as follows:
tell application "Microsoft Excel"
activate
set TheFileToOpen to "/Users/JoelC/Documents/Projects On The Go/Budget and Spend Tracking/20140101_budget and expenditure.xlsx"
set TheWorkBook to "20140101_budget and expenditure.xlsx"
set TheWorksheet to "Budget_2021"
set ThePassword to "abcdefgh"
open TheFileToOpen
unprotect workbook TheWorkBook password ThePassword
unprotect sheet TheWorksheet password ThePassword
end tell
I would GREATLY appreciate any and all help in getting this to work.
Thanks!