How To: Create and Use Macros

How often do you find yourself typing the same information, such as your school name and address, into document after document? Or using the same sequence of menu commands, such as saving a file in a specific folder (File, Save, navigate to the folder, open the folder, save the file)? Would you rather use a short key combination that performs these repetitive data-entry tasks for you (such as having your full name appear when you type in your initials)? In many computer applications, creating and using macros — lists of instructions that are automatically executed, usually by pressing a specific key combination — allows you to do exactly this.

Creating Macros

A Macro can be as simple or complex as you need. For example, you can create a macro that changes all text to a specific font, reformats your page margins, and then saves it in a specific folder. Or, a macro can type a specific string of text for you.

Macros are usually created by "recording" them — you perform a sequence of keystrokes once, give it a name and/or shortcut key combination, and the computer remembers it. For example, in Microsoft Word you begin by choosing the Record Macros command from the appropriate menu; you then type your text. When you are done, click the stop button — and your macro is recorded.

Built-in Macros

Some word processors have already built in a number of commonly used macros which do things like insert the date or current time. These are available through a menu choice or key combination. Other common built-in macros are salutations and letter closings, such as "Dear Sir or Madam" or "Respectfully yours."

Using Macros

To use a macro, either select it from a menu or press the appropriate key combination. In some programs, it is even possible to add a macro as a button to a toolbar so that you only need to click it to invoke it.

Macro Viruses

Some programs have such sophisticated macro capability that it is possible to include a computer program ("executable code") as part of a macro. What if somebody creates a macro that includes a virus program, embeds it within a file, and sets it up to begin working as soon as the file is opened? This has happened, primarily with Microsoft applications such as Word, Excel, and Outlook. However, as long as you keep your virus definitions up to date, you will be protected. All major antivirus companies include protection against macro viruses.

Jeffrey Branzburg is a contributing editor and regular columnist for Technology & Learning.

Tags