Script Solutions for Word 2008

compiled by Daiya Mitchell

Office 2008 does not support any VBA or macros; however, Microsoft has announced that VBA will return in the next major version of Office (version meaning Office 14, not an update to Office 2008. Office 2008 is Office 12—both Mac and WinOffice skipped Office 13. The MacBU expects to be releasing future versions of Office on a more regular 2-3 year cycle, now that the OS X and Intel transitions are complete).

For Office 2008, AppleScripts and Automator can replace many of the macros for home use. This page strives to index available replacements and guide you to options; suggestions for new links are welcomed, and would be best posted on the Word newsgroup. (You can also investigate third-party programs such as QuicKeys or Keyboard Maestro, recommended by some newsgroup posters. While more expensive, these programs can streamline your activities in all applications, not just Word.)

If you have a script that you think will help others, we'd love to link it here, or re-publish with full author credit for you, if you prefer. But scripts are probably best hosted at the repository at Scriptbuilders.net.

I Need to Replace a Macro

If you are searching to replace a function that you don't see indexed here, post a request in the Word newsgroup (more information on using newsgroups). Maybe someone will write the script for you.

Alert! a number of people have requested scripts to accomplish functions that are already built into Word, so it's always worth describing what you want to do. It might not require a script at all.

Word AppleScript Resources

People comfortable with code and wanting to delve into AppleScripting Word might start with the VBA-to-AppleScript Transition Guide. Download the Word 2004 AppleScript Reference from there—Word 2004 had robust AppleScript support and the reference offers many valuable examples (it's likely that scripts will work in both Word 2008 and Word 2004). The sample scripts on this page may also supplement your efforts. You may find more useful samples among the results for "AppleScript" in the Word newsgroup. There are a few questions and answers in Apple's AppleScript forum. Another valuable resource is MacScripter. Knowing the VBA for what you want to do can help you search for the right AppleScript terms, which are usually modified versions of the VBA, so your defunct macros will also be a useful resource.

Why Did MS Remove VBA?

A MacBU developer explained the decision to remove VBA here. And then discusses the decision to bring it back.

Things AppleScript Cannot Do

This is an in-progress list of structural limitations, not specific bugs.

AppleScripts cannot be put on a Word toolbar.

AppleScripts cannot be embedded into a document or template and distributed with the Word file, although you can certainly send them to other Mac users separately with installation instructions.

You cannot call AppleScript from within the document. This means Macrobutton fields cannot be replaced. Similarly, you cannot automate forms. Word 2004 allowed you to write Entry and Exit macros that would activate on tabbing into or out of a form field. AppleScript cannot do this.

AppleScript has no equivalent for AutoOpen or AutoExec macros. An alternate approach for AutoExec would be to always launch Word by using a script that carried out your AutoExec routine and then launched Word. If you find an alternate approach for AutoOpen macros, which run on every document you open, please share.

Automator

The full version of Office 2008 comes with over 90 pre-built Automator actions that you can assemble into workflows, including, for instance, a way to Save As PDF in a single step. The included Sample Automator Workflows (under the script menu in Word) can be duplicated and edited to suit you.

The Home and Student version can use Automator, but does not include the pre-built actions.

TUAW Automator Tutorial: Part I (Word)

If you think of Automator actions that you would use, let MS know by using Help>Send Feedback in Word. Describe your workflow to MS so that they have a better sense of customer needs.

Basic Principles

Install an AppleScript

Assign a Keyboard Shortcut to an AppleScript (external link)

Index to Scripts on Other Sites

Change Language in a Single Click (Corentin Cras-Méneur)

Paste Plain Text (TidBits has a variant solution)

Delete from Work Menu (Scriptbuilders.net—search there for "remove work" if this link is broken)

Clean Up Email Formatting (David Pogue at NYT)

Scriptbuilders.Net—a repository of scripts for many programs, from all over.

Macworld articles by Joe Kissell: Part I (Paste Plain Text, Enclose in HTML Tags, Clean Up Text) Part II (Toggle Keep with Next, Insert Boilerplate, Remove from Work Menu).

Index to Scripts Hosted Here

Script Caveat

Office 2008 launched on 15 January 2008. It will take time for the third-party scripting community to take full advantage of AppleScript in Word.

At present, your host on this webpage is one person, a volunteer recognized by MS for helping other people use Word, who is a novice at AppleScript, begging and borrowing code from "real" AppleScripters to share with the public in a form usable by people who don't know AppleScript at all. This webpage and its links will attempt to walk you through customizing the scripts to fit your preferences.

Test them on a COPY of your document and use at your own risk!

There is no real support for the scripts hosted here, but problems may be posted in the Word newsgroup. I tested all of them on my machine, running OS X 10.4.11 (PPC) and Office 2008. Most of them are minor scripts that should not do any harm even if they break, but take reasonable precautions.

With luck, this will be a temporary situation, replaced by better options in the future.

Scripts

Arrange All Windows Vertically

Set Window Size, View, Zoom, Location, and Toolbars in One Click

Paste Text Only or Paste Text Matching Destination Format