Macbook功能在Office for Mac 2016中运行不正常!有任何想法吗? [英] The MacScript function is not working well in Office for Mac 2016! Any ideas?

查看:206
本文介绍了Macbook功能在Office for Mac 2016中运行不正常!有任何想法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

我的宏使用MacScript,但在最新的Office for Mac 2016预览版本中似乎没有工作。

用于在Office for Mac 2011中支持内联Apple脚本的 MacScript 命令已被弃用。由于沙盒的限制, MacScript 命令无法再调用其他应用程序,例如Finder。所以我们不鼓励使用这个命令。
对于需要更改现有代码,因此不使用 MacScript 的情况,您可以使用 AppleScriptTask 命令(见下文)。



新的 AppleScriptTask 命令执行AppleScript脚本。这类似于 MacScript 命令,除了它运行位于沙盒应用程序之外的AppleScript文件。
调用 AppleScriptTask 如下:

  Dim myScriptResult as String 

myScriptResult = AppleScriptTask(MyAppleScriptFile.applescript,myapplescripthandler,我的参数字符串)

其中:




  • MyAppleScript.applescript文件必须在〜/ Library / Application Scripts / [bundle id] /,扩展名 applescript 不是强制性的,.scpt也可以使用

  • myapplescripthandler是MyAppleScript.applescript中脚本处理程序的名称文件

  • 我的参数字符串是myapplescripthandler脚本处理程序的单个输入参数。

  • 相应的AppleScript for Excel将位于〜/ Library / Application Scripts / com.microsoft.Excel /
  • $ b $中的名为MyAppleScriptFile.applescript的文件中b


注意:Mac Word,Excel和PowerPoint的[bundle id]是:




  • com.microsoft.Word

  • com.microsoft.Excel

  • com.microsoft.Powerpoint



一个处理程序的例子如下:

  myapplescripthandler (paramString)

#do与paramString的东西
返回你告诉我& paramString

end myapplescripthandler


My macros use MacScript heavily, but it doesn't seem to be working in any of latest Office for Mac 2016 preview builds

解决方案

The MacScript command, used to support inline Apple Scripts in Office for Mac 2011, is being deprecated. Due to restrictions of the sandbox, the MacScript command can no longer invoke other applications such as the Finder. Therefore we discourage the use of this command. For cases which require changing your existing code so it doesn’t use MacScript, you can use the AppleScriptTask command (see below).

The new AppleScriptTask command executes an AppleScript script. This similar to the MacScript command except that it runs an AppleScript file located outside the sandboxed app. Call AppleScriptTask as follows:

 Dim myScriptResult as String

 myScriptResult = AppleScriptTask ("MyAppleScriptFile.applescript", "myapplescripthandler", "my parameter string") 

Where:

  • The "MyAppleScript.applescript" file must be in ~/Library/Application Scripts/[bundle id]/, the extension applescript is not mandatory, .scpt may also be used
  • "myapplescripthandler" is the name of a script handler in the MyAppleScript.applescript file
  • "my parameter string" is the single input parameter to the "myapplescripthandler" script handler.
  • The corresponding AppleScript for Excel would be in a file named "MyAppleScriptFile.applescript" that is in ~/Library/Application Scripts/com.microsoft.Excel/

Note: The [bundle id]s for Mac Word, Excel and PowerPoint are:

  • com.microsoft.Word
  • com.microsoft.Excel
  • com.microsoft.Powerpoint

An example of a handler is as follows:

on myapplescripthandler(paramString) 

    #do something with paramString 
    return "You told me " & paramString 

end myapplescripthandler

这篇关于Macbook功能在Office for Mac 2016中运行不正常!有任何想法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆