2017-09-24 2 views
0

Diese Frage wurde schon einmal gestellt, aber die vorgeschlagenen Antworten (auf "VBA Shell-Funktion in Office 2011 für Mac") scheinen nicht zu funktionieren.Gibt es eine Möglichkeit für VBA (in Office 2011 für Mac), ein AppleScript auszuführen?

Mein Applescript, Run_Script.scpt, erstellt eine kleine TXT-Datei. Es läuft perfekt im Editor. Es läuft auch perfekt, wenn es als App kompiliert wird und auf den Desktop doppelgeklickt wird.

Ich muss es von einer VBA-Prozedur aufrufen. Ich habe versucht, diese:

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 

Ich habe OS X El Capitan 10.11.6. Ich verwende Office 2011 für Mac. Excel wurde auf 14.7.2 aktualisiert.

Was mache ich falsch?

Antwort

1

Auf ElCapitain mit Excel 2011 (14.0.0) werden die 2 folgenden Makro ausgeführt. Sie müssen den Pfad zu Ihrer drive/users/script Datei anpassen.

Aufruf eines Skripts in VBA-Makro:

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

eine App in VBA aufrufen Makro:

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

Diejenigen perfekt funktionieren! Vielen Dank! –

Verwandte Themen