How to Install an AppleScript
If someone on a newsgroup or listserv gave you an assortment of words to fix a problem, and the words start with “tell” and mostly look like English, that’s probably an AppleScript. Here is how you put the AppleScript into a form you know how to use. [This page is geared toward using AppleScripts in MS Word but the information should translate to most scriptable applications.]
1. Launch Script Editor. Script Editor is located inside the AppleScript folder in the Applications folder. It is included in all versions of the Mac OS.
2. Copy the script into a new window in Script Editor. Click Compile on the Script Editor toolbar—the script will reformat itself if there are no errors. If the script has errors, it will give you an error message and highlight the incorrect spot. The most likely reason for an error showing up would be a line break in the wrong place, caused by copying and pasting from email, which often forces shorter lines.
3. Click Run in Script Editor. The script will run, and should do whatever it is supposed to do. You might consider testing scripts you get from other people on a COPY of your document, just to prevent worst-case scenarios.
To Easily Use the Script Again and Again
Scripts are accessed from a script menu. Some applications (such as MS Entourage) have their own script menu to access scripts. MS Word does not, yet (as of Office 2004), so scripts for use in Word must be accessed from the main script menu.
4. If there is no Script Menu on the right side of your OS X menubar, go back to Applications/AppleScript/ and double-click Install Script Menu. You should see an icon like this in the menu bar: ![]()
5. Save the script in ~/Library/Scripts/, setting the Format to "script" in the Save dialog. Let the OS add the ".scpt" extension if it so chooses. All scripts saved in ~/Library/Scripts/ are available from the main script menu in OS X. (~ is short for your username or home folder in OS X, so availability will be specific to that user account.)
6. Simply select the script from the main script menu whenever you want to run it.
Prevent Clutter in the Main Script Menu
As you accumulate AppleScripts for use in MS Word and other programs without their own script menu, the main script menu can get a little crowded.
- You can select Hide Library Scripts in the main script menu, to prevent the built-in scripts from cluttering your script menu.
- You can easily categorize your scripts by creating subfolders in ~/Library/Scripts/ that will be reflected in the menu.
- If many of these scripts will only be run from inside a particular application, you can set up a folder structure that hides them unless you are in that application. Create a folder "Applications" in ~/Library/Scripts/. Create subfolders of Applications that have the exact same name as the application. For instance, scripts in a subfolder ~/Library/Scripts/Applications/Microsoft Word/ will only appear when the active window is an MS Word document. Keep in mind that there may be Word-specific tasks—say, launch a document—that you will want to do from outside Word.