Moving from Microsoft Office VBA to AppleScript:
MacTech's Guide to Making the Transition
Introduction
|
Table of Contents
Page Prev and Page Next buttons at bottom of the page.
|
April, 2007
Page 6
Unlike Entourage, which has had its own script menu from its inception, Word, Excel and PowerPoint 2004 do not have their own script menus. (It‘s always possible that the next version might introduce these, which would allow for keyboard shortcuts such as Entourage does.)
But the OS has its own script menu. To enable it, in Tiger OS 10.4 go to /Applications/AppleScript/AppleScript Utility and double-click it. Click "Show scripts menu in menu bar" checkbox and close. (In Panther OS 10.3, go to /Applications/AppleScript/Script Menu.menu and double-click it.) Now you will see a black "squiggly-S" icon on the right-hand side of the main menu bar, near the menu clock:
^ System Script Menu
Click the menu, then Open Scripts Folder/Open User Scripts Folder (in Panther, there is no sub-item). This creates and opens a "Scripts" folder here: ~/Library/Scripts/, where ~/ means your username Home folder (Mac HD/Users/username/). This is where you will store your scripts to make them appear in the same menu – you just select a script name in the menu and it runs.
If the menu starts to get too long for comfort, and you‘d like to see some or all of your Word scripts, say, only when Word is in the front, make an "Applications" subfolder inside this Scripts folder, and then a "Microsoft Word" (and a separate "Microsoft Excel" and "Microsoft PowerPoint" and whichever other applications you‘d like to do the same for) subfolder inside the "Applications" folder. You must spell out the full name of the application exactly as it appears on your computer or it won‘t make the match to the application. You can do all this automatically in OS 10.4 (and later, presumably) by bring Word or any application to the front, clicking the Script menu, and choose Open Scripts Folder/Open Microsoft Word Scripts Folder: this creates the folder if it does not yet exist. Now any scripts saved in the Microsoft Word subfolder will be seen in the Scripts menu only when Word is the active application in the front. (So don‘t put scripts in there that you want to call from another application or the Finder to get Word going.)
This is one great advantage AppleScript has over VBA: You can call a Word script from, say, Entourage or FileMaker Pro, to take some selected text, for example, and use it in a Word document, perhaps even doing it all automatically in the background. It is certainly a limitation that you cannot call scripts from a button on a Word toolbar nor (yet) from a keyboard shortcut (at least not without a third-party utility such as iKey, DragThing or QuicKeys: see the Resources chapter for URLs), but the Scripts menu is nevertheless and excellent device for running scripts with no overhead. In the next chapter I discuss some third-party tools that can provide palettes with buttons for running scripts, and even toolbars you can make yourself if you are up to it.
< Previous Page Next Page>
- SPREAD THE WORD:
- Slashdot
- Digg
- Del.icio.us
- Newsvine