2017-09-24 9 views
0

この質問はこれまでに依頼されていますが、「Office 2011 for Mac 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エルキャピタン10.11.6を持っています。私はOffice 2011 for Macを実行しています。 Excelが14.7.2に更新されました

何が間違っていますか?

答えて

1

Excel 2011(14.0.0)のElCapitainでは、次の2マクロが実行されています。 ドライブ/ユーザー/スクリプトファイルのパスを調整する必要があります。

マクロVBAでスクリプトを呼び出す:

s = "run script (""ElCapitain:Users:imac27:Desktop:Test_Script.scpt"" as alias)" 
Temp = MacScript(s) 

マクロVBAでアプリを呼び出す:

s = "run script (""ElCapitain:Users:imac27:Desktop:Test_App.app"" as alias)" 
Temp = MacScript(s) 
+0

これらの仕事を完璧に!どうもありがとうございました! –

関連する問題