Thursday, September 20, 2018

#1 2018-09-14 08:21:35 am

Schrocks
Member
Registered: 2018-09-03
Posts: 1

Getting past Excel's security

Very green apple scripter here and it's my first post here as well.  Sorry if it shows.  I have a Mac Excel 2011 file that I want to start up in the middle of the night and run an embedded macro.  I'm on OSX 10.12.6.  The macro includes accessing a database on our network.  I found clues as to how to get past Excel's macro warning here: https://macscripter.net/viewtopic.php?id=34453 and I was able to make it work. 

However, once I am in the spreadsheet, I still have a banner across the top of the spreadsheet that says "Security Warning  Data connections have been disabled".  This is due to the fact that the macro queries a database.  As a person, I can just click on the Enable Content button and my macro runs fine, but I don't know how to automate clicking that button.  Can anybody point me in the direction of where to find the name of the window and button (or if that is even the right approach for this button)?

Here is my code:

Applescript:


tell application "Finder"
   activate
   open document file "somefile.xlsm" of folder "Folder1" of folder "Folder2" of folder "Folder3" of startup disk
   delay 2
end tell

tell application "System Events"
   tell process "Microsoft Excel"
       set macros to button "Enable Macros" of window 1
       click macros
       -- delay 5
       -- set content to button "Enable Content" of window 2
       -- click content
   end tell
end tell

If I un-comment the 3 lines towards the end, I just get an error.  It doesn't click the button.  Thank-you,
Lyle

Model: Mac Mini (Late 2014)
AppleScript: 2.5
Operating System: Mac OS X (10.12.6 beta 6)


Filed under: excel, Enable Content

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)