0
此問題之前已被問到,但建議的答案(「Office 2011 for Mac中的VBA Shell函數」)似乎不起作用。VBA(Office 2011 for Mac)有沒有辦法運行AppleScript?
我的Applescript,Run_Script.scpt創建一個小的txt文件。它在編輯器中完美運行。編譯爲應用程序並雙擊桌面時,它也可以完美運行。
我需要從VBA過程中調用它。我試過這些:
Sub sub_scripttest()
Dim i As Integer
Dim result_long As Long
Dim result_str As String
'//== the original question was this:
result_str = Shell("Macintosh HD:Applications:Run_Script.app", vbNormalFocus)
result_str = Shell("Macintosh HD/Applications/Run_Script.app", vbNormalFocus)
'//== gives a modal dialog box: "Runtime error 53: File not found"
'//== the suggested solution was this:
result_str = MacScript("do shell script ""Macintosh HD:Applications:Run_Script.app""")
result_str = MacScript("do shell script ""Macintosh HD/Applications/Run_Script.app""")
'//== gives a modal dialog box: "Runtime error 5: Invalid Procedure call or Argument"
'//== another suggested solution was this:
result_long = system("Macintosh HD:Applications:Run_Script.app")
result_long = system("Macintosh HD/Applications/Run_Script.app")
'//== appears to run, but returns result_long=32512, which is not a successful termination code.
'//== also the desktop shows that the script did not run. The txt file was not created.
'//== I even tried:
result_str = AppleScriptTask("Run_Script.scpt", "my_command", "")
'//== and got: "Compile Error: Sub or Function not defined."
End Sub
我有OS X El Capitan 10.11.6。我正在運行Office 2011 for Mac。 Excel已經更新到14.7.2
我在做什麼錯?
那些很好地工作!非常感謝你! –