My macros use MacScript heavily, but it doesn't seem to be working in any of latest Office for Mac 2016 preview builds
相关问题
- Excel sunburst chart: Some labels missing
- Error handling only works once
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
相关文章
- Get column data by Column name and sheet name
- programmatically excel cells to be auto fit width
- Unregister a XLL in Excel (VBA)
- Unregister a XLL in Excel (VBA)
- How to prevent excel from truncating numbers in a
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- What's the easiest way to create an Excel tabl
Perhaps the most frustrating part of the lack of support is the "workaround" of creating the folder structure and script files.
To solve this problem, I created an AppleScript that runs like an installer to set up the AppleScript folder and files that you need to pass along with your VBA application for AppleScriptTask to work. I utilized the "FileExists" and "FolderExists" examples from Ron De Bruin's website (http://www.rondebruin.nl/mac/applescripttask.htm). Those two functions are below and are used to determine if a File or Folder Exists:
You can run the below script by saving it to a file called "InstallFileFolderScript.scpt". It does two things:
Feel free to modify it to add additional functions as needed for the application. Each line of the script file is written using this script. It can also be modified to work with Excel and other office Apps:
Finally, within the VBA application I use this to call the AppleScript functions:
I also found this Microsoft article very helpful and easy to understand: https://dev.office.com/blogs/VBA-improvements-in-Office-2016. It details usage of AppleScriptTask, and also covers the folder permissions workaround that you commonly will have to implement alongside AppleScriptTask when working with files/folders.
The
MacScript
command, used to support inline Apple Scripts in Office for Mac 2011, is being deprecated. Due to restrictions of the sandbox, theMacScript
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 theAppleScriptTask
command (see below).The new
AppleScriptTask
command executes an AppleScript script. This similar to theMacScript
command except that it runs an AppleScript file located outside the sandboxed app. CallAppleScriptTask
as follows:Where:
Note: The [bundle id]s for Mac Word, Excel and PowerPoint are:
An example of a handler is as follows: