Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Writing a Macro from Scratch.

Writing a Macro from Scratch

by Allen Wyatt
(last updated September 8, 2012)

3

Many of the tips used in WordTips rely upon macros in order to run. Some readers may not know how to enter a macro from scratch in Word. There are actually two ways you can create macros. First you can record a macro, which is appropriate when you want to record a series of steps you perform quite often. The second method of creating a macro, writing one from scratch, is much more powerful.

To create a macro from scratch, follow these steps:

  1. Choose the Macro option from the Tools menu, then choose Macros from the resulting submenu. Word displays the Macros dialog box. (You can also display the Macros dialog box by simply pressing Alt+F8.)
  2. In the Macros In box (at the bottom of the dialog box), select where you want your new macro stored. Select Normal.dot (Global Template) if you want your macro available in all documents; select a different template if you want the macro available only with the current document template. You can even assign a macro to a specific document.
  3. In the Macro Name box, type a descriptive name you want assigned to the macro you are writing. Optionally, you can enter information in the Description box.
  4. Click on Create. The VBA Editor is started and you can write your macro.
  5. When you are through, close the macro window by selecting the Close and Return to Microsoft Word option from the File menu, or press Alt+Q.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (109) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Writing a Macro from Scratch.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Converting Footnotes to Endnotes

When you spend a lot of time creating footnotes, how can you convert all of them to endnotes without entering them all again? ...

Discover More

Inserting the Date and Time

Inserting a date and time in your document is a snap using the tools provided in Word. Just pick the command, then specify ...

Discover More

Clip Art Sizing Difficulties

A discussion of problems a reader was having resizing clip art in Word.

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

MORE WORDTIPS (MENU)

Saving in Document Format from a Macro

Saving a document in a different format is easy if you are manually using the Save As command. Saving a document in an ...

Discover More

Can't Save a Macro

Macros can make your use of Word faster and easier than ever before. What do you do, however, when you try to save a macro ...

Discover More

Counting Open Document Windows

When creating macros, it is sometimes necessary to know how many documents are open in Word. This is relatively easy to do ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is one more than 2?

2017-01-17 05:14:46

Ken Endacott

What you want to do could be done by Find & Replace which would be much easier to learn to drive than to learn to write macros.


2017-01-16 17:51:18

Bill Holder

Hate to bother you for I know you are a very busy person, but I am needing help.

I am trying to write a Macro that will do the following;
Find the CHAPTER
Highlight that word and move over 3 spaces
Then make it to have a Heading 2
Then do a Return
Then Loop through the rest until all CHAPTER have been reformatted.

Can't seem to get to loop, I did once but it looped so many I had to use ALT-CTRL-DELTE to stop the program, Word.

Any help woud be greatly appreciated,
Bill


2015-10-28 15:34:10

Arthur Filz

How do you write a macron in Microsoft Word to search for a file. I saw it done in Excel


Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing
Share