How to Run a AppleScript from VBA using AppleScriptTask

Newbie here…discovering AppleScript and after following many examples to thankfully have them work perfectly by being called from an Excel VBA module, I’m simply baffled on how to accomplish a “custom” simple task of executing a script from VBA. My goal is to have VBA code run a script to then select a validation cell and show the drop down list items. Simple right? Well this neanderthal can’t make it happen. Must be missing something so basic and right in my face that will have everyone laughing at me. I’m ready for the ridicule. Here is my basic code:

VBA:

Sub Test() 
Dim RunMyScript As Boolean   
Dim FilePathName As String  
FilePathName = "/Users/scott/Library/Application   Scripts/com.microsoft.Excel/Validation Drop Down Arrow Script.scpt"  
RunMyScript = AppleScriptTask("Validation Drop Down Arrow   Script.scpt", "ArrowDown", FilePathName)  
End Sub

Script:

on ArrowDown()  
tell application "Microsoft Excel"  
activate  
delay 0.1   
select range "G2"  
tell application "System Events" to key code 125 using option down  
end tell  
end ArrowDown  

*Note: The script works fine when run from script editor but fails endlessly no matter how I try to call it from VBA. Very frustrating and has increased my beer intake this week.

Leave a Comment