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: Assigning a Macro to a Button in Your Text.
by Allen Wyatt
(last updated July 18, 2015)
You already know you can assign a macro to a button (a tool) on your toolbar. Word also allows you to add buttons within the text of you document. These buttons have a macro or a Word command assigned to them, and you can control what happens when the button is selected in text. This is all instituted through the use of a field code. It may be a bit of a misnomer to refer to the result of this field code as a "button," because no graphics are involved whatsoever, although you can create your own graphic and embed it into the field. The syntax for the field code is:
MacroButton MacroName Display
MacroName is the name of the macro or command you want to run, and Display is the text you want displayed by the field code. If you use a graphic instead of text, then the graphic is displayed. When a user double-clicks on the displayed text or graphic, then the macro or command defined by MacroName is executed.
To assign a command or macro to a button, and insert that button in your text, follow these steps:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1571) 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: Assigning a Macro to a Button in Your Text.
The First and Last Word on Word! Bestselling For Dummies author Dan Gookin puts his usual fun and friendly candor back to work to show you how to navigate Word 2013. Spend more time working and less time trying to figure it all out! Check out Word 2013 For Dummies today!
Part of developing macros is learning how to use and manipulate variables. This tip examines a technique you can use to ...Discover More
When creating macros, you often need to convert a text string that contains numbers into actual numeric values. You do ...Discover More
Need to run one macro from within another macro? You can easily do it by using the Run method of the Application object, ...Discover More
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.