Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Assigning a Macro to a Button in Your Text.
by Allen Wyatt
(last updated August 12, 2017)
You may already know that you can only assign a macro to a button (a tool) on the Quick Access 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 (8658) applies to Microsoft Word 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Word here: Assigning a Macro to a Button in Your Text.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
When you use the FILENAME field in a document, it can include the full path name that leads to your file. This might be too ...Discover More
Want to start a new heading on an odd-numbered page? You can do it with section breaks, obviously, but you can also do it ...Discover More
One of the properties you can specify for a document is a subject. You can then use a field code to insert this subject, ...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 ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.