What's a macro good for?

What's a “macro?”

Think of a macro as a shortcut. Similar to the way a keyboard shortcut can do the same thing as pressing a button on a toolbar or menu, a macro can do a sequence of actions that you do over and over. You can't type a paragraph of your essay then have a macro repeat the process of making up a paragraph to type, but you can have a macro repeat typing in the whole paragraph (if you were so inclined). A macro can do more than just type, though. Suppose you had to set the margins and tab stops on every new document you made. You could make a macro to do that for you, and hook that macro up to a keyboard shortcut or toolbar button. This would make the procedure quick and accurate – the macro won't accidentally put your margin at 1.45” instead of 1.5” as a person might.

Getting started with macros

In this article, we're going to focus on macros in Microsoft Word and Microsoft Excel.  I'll use examples from Word most of the time, but almost everything applies just as well to Excel.

The easiest way to illustrate what a macro can do is by recording one of your own.  To do this, start Word and choose "record" from "tools" - "macros."  Type some text - like "Rob is the best." (this is a old favourite from back in grade 2; put your own name in there and you can feel the power).  Now double-click "best" and add some emphasis - turn on bold (that is, press ctrl-b).  Click the stop button and Word will stop recording your actions.

That's how easy it is to make a macro.

Now you can play back the macro you just recorded.  Just go to Tools-Macro-Macros and you'll see a list of available macros.  Odds are there are not many in the list, yours is called "Macro1."  Pick it from the list and press the "Play" button.  Pretty slick, eh?

Now we notice something else.  There was a lot of clicking to get to the record and play buttons.  That cuts into any time a macro can save.  Here's a way to speed things up (you only have to do this once): Go to "Tools"-"Customize" and choose the "Toolbars" tab.  There are a list of toolbars that Word can show.  A toolbar is just a name for the row of buttons at the top of Word.  Put a check in the box next to "Visual Basic."  Press the Close button, and you can see there are a few new buttons available at the top of Word.  The circle is the record button, and the triangle is the play button. I hope I'm not the only one that remembers this from VCRs...

So now back to the macro at hand. Admittedly this one is pretty specialized - it's main function being to impress gradeschool kids.  Still, the reason that I chose something so simple is to point out that even a simple macro can be useful.  Don't believe me?  Good: that shows you're thinking.  Here's a practical example that's just as simple to make as our facetious one:

(make attachment here)

Seuss maintains the unsupportable position that the eggs of a Stroodle are gooey like glue [T. Geisel, Green Eggs and Ham, 1970]...

You've just finished your essay and you're double checking it.  Your endnotes all are enclosed in brackets (like [author]).  You forgot they should be first initial and last name only.  I'm sure there are a few ways to fix this but the one that springs to mind is a macro.  Just record yourself as you press ctrl-f, [, enter, ctrl-shift-right, .  There's a macro that leaves the first letter of the name, a period and the last name.  All you have to do is run it over and over until all the end notes are fixed.