Save valuable time with the help of macros and AutoCorrect in Word
One of the most frustrating aspects of any computer user’s life is having to perform the same actions over and over, whether it’s typing the same phrase time and time again or clicking through a series of menus and dialog boxes repeatedly. Thankfully, Word has several useful tools designed to help you save time performing repetitive actions. (Excel and PowerPoint have many of the same features.)
Some of Word’s most useful tools are based on its AutoCorrect engine. It’s capable of quite a lot, but its main use is to quickly correct typos. If you’re lucky, some typos are automatically corrected by AutoCorrect, but it often needs a helping hand.
Word flags suspect or regularly misspelled words with a red wavy line. Right-click this, select AutoCorrect, and a list of suggested alternatives appear. If the correct spelling is there, select it and Word not only replaces the suspect word, but it automatically corrects the same typo in the future. (Note that the feature is case-sensitive, so Word won’t correct «Thst» and «thst» with the same AutoCorrect entry.)
Sometimes this behavior isn’t what you want, though, which is why AutoCorrect displays a smart button after making a change. Click this and you can either undo the action for this instance only, or instruct AutoCorrect to stop automatically correcting this word. The latter option deletes any AutoCorrect entry you may have set up previously.
You can use AutoCorrect in other ways, too —to quickly insert symbols that aren’t easily accessible via the keyboard, for example, or to generate math equations. It’s also linked in with AutoFormat, which corrects formatting as you type, and AutoText, which lets you store long chunks of text that can be triggered simply by typing the first few words of the phrase.
Want to automate more than just text entry? You can use macros, Word’s equivalent to AppleScripts. Macros are built using a special programming language called Visual Basic for Applications (VBA). Support for VBA was dropped in Office 2008, but is back with a vengeance in Office 2011.
Learning VBA from scratch can be quite daunting, so the good — if slightly ironic—news is that Office has a tool for automating the creation of macros. It «records» a series of commands you perform, such as selecting an option from a dialogue box and then formatting a piece of text. Your sequence of commands is stored in the macro, and running the macro then repeats all the actions you’ve recorded. Once created, the macro can be placed on a toolbar, in a menu, or assigned a keyboard shortcut to activate it.
Macros are stored within your Word documents rather than within Word itself. This means they’re portable and can travel with your files onto other machines. By default, new macros are assigned to the default blank template, so all future files you create contain the macro, but this can be changed.
Because macros contain VBA code, it’s possible for them to be hacked and contain viruses and other malicious software. This is a problem largely confined to PCs, which have fewer limits than Macs on what scripts are allowed to do, but it pays to be safe rather than sorry: Word always alerts you when you open a document containing a macro from another source, such as the Internet or another computer. This is useful in that it allows you to block the macro or even prevent the file from opening, if you’re not entirely confident about it.
1. Test the Macro
To verify that the macro works, click its button in the toolbar or press the keyboard shortcut. If it doesn’t work as planned, the simplest thing to do is delete it (click Macros on the ribbon, select the unwanted macro, and click Delete), then start over.
2. Press Record
The easiest way to create a macro is to «record» your keystrokes, clicks, and commands. Just click Record on the ribbon, and first give your macro a recognizable name—but note that this can’t include spaces or special characters, only letters and numbers, eg., «InsertLogoRotateCrop.»
3. Select Options
You can place the macro on a toolbar or assign it a keyboard shortcut for convenient access. By default, macros are stored in the Normal template; you can, however, limit the macro to the current document only. Enter a description as a reminder of what the macro does, then click OK.
4. Perform Your Actions
Perform each step of the action that makes up your macro, be it mouse click, menu command, or keystroke. You can click Pause at any time—no actions are recorded while paused—and then click Resume to continue recording. Click Stop to finish.
You can access macro-recording tools via Tools > Macro. From here, you can view existing macros, record a new macro, or open the Visual Basic Editor. Alternatively, place the macro tools on the ribbon: click the cog at the far right and select Ribbon Preferences…. Scroll down and tick the Developer option at the bottom of Print Layout View, then OK.
6. The Organizer Click
Macros on the Developer tab to access a list of pre-defined macros. Click Organizer… and you can copy macros from the current document to the global template and back again. You can also copy other items, including paragraph and text styles, AutoText entries, and custom toolbars.
7.A Edit the Code
Advanced users can fine-tune macros by editing the underlying VBA code. Click Editor on the Developer tab of the ribbon, select your macro from the list, and the code appears in its own window. You can access the VBA documentation for Office 2011 at http://bit.ly/14iDgPg, but a good place to start learning VBA is at the Word MVPS site: go to http://bit.ly/14a1Guk to acquaint yourself with the Visual Basic Editor, and visit http:// bit.ly/16LBru8 for another guide with links to further articles.