osx - Running Applescript from Excel 2011 VBA -
mac os x, excel 2011 vba question: trying run bash shell excel 2011 macro. command executes mac os x lion 10.7.5 terminal. executes correctly using applescript command line:
osascript -e 'do shell script "/users/myfolder/desktop/myshell"'
i can execute ./test.sh, test.sh executable (chmod +x test.sh) file including lines
#!/bin/bash osascript -e 'do shell script "/users/myfolder/desktop/myshell"'
from excel, able execute similar test.sh file
#!/bin/bash open /applications/calculator.app/
using excel vba function code
function testshell() double shell activeworkbook.path & ":test.sh" testshell = 0 end function
however, when switch test.sh file have desired content (the applescript command uses osascript above), fails. 1 further aspect of pathology if erase test.sh file, replace it, on first run put window saying 'this file internet. still want run it?'. in case, after clicking ok code appears run, doesn't execute correctly, though function exits no errors. but, invariably, if try run again, gives me
run-time error '75' path/file access error
and function crashes.
for little more context, 'myshell' script (not real name) written take arguments file, because found documentation online excel on macos couldn't run script input arguments via 'shell' in macro. haven't had problem writing argument input file. difficulty getting test.sh script executes 'myshell' script execute. i'm not regular vba programmer, i've looked through many webpages , found lot of differences between pcs , mac os x, have not been able find solution simple problem. suggestions appreciated.
ok. answering own question: run shell script, needed make applescript .app file did needed applescript utility. so, inserted original shell script call applescript utility
do shell script "/users/myfolder/desktop/myshell"
compiled myshell.app, called shell script test.sh ran excel macro with
function testshell() double shell activeworkbook.path & ":test.sh" testshell = 0 end function
where test.sh contained
#!/bin/bash open /users/myfolder/desktop/myshell.app/
a pretty roundabout way of getting wanted done done, needed excel on mac os x. in end (not shown here), able parameters shell script writing them excel macro file. ran myshell.app. had shell output written file read excel macro.
Comments
Post a Comment