Applies ToWord for Microsoft 365 Word for Microsoft 365 for Mac Word 2021 Word 2021 for Mac Word 2019 Word 2019 for Mac Word 2016

The MacroButton field Inserts a macro command, which you can run by double-clicking the results of a MACROBUTTON field. You can also click in the MACROBUTTON field and then press ALT+SHIFT+F9.

Security Note:  Because macros can contain viruses, be careful about running them. Take the following precautions: run up-to-date antivirus software on your computer; set your macro security level to high; clear the Trust all installed add-ins and templates check box; use digital signatures; maintain a list of trusted publishers.

Syntax

When you view the MacroButton field in your document, the syntax looks like this:

{ MACROBUTTON MacroName DisplayText }

Note:  A field code tells the field what to show. Field results are what’s shown in the document after having evaluated the field code. To toggle between viewing the field code and the field code results, press Alt+F9.

Instructions

MacroName

The name of the macro to run when you double-click the field result. The macro must be available in the active documenttemplate or a global template.

DisplayText

The text or graphic to appear as the "button." You can use a field that results in text or a graphic, such as BOOKMARK or INCLUDEPICTURE. The text or graphic must appear on one line in the field result; otherwise, an error occurs.

Example

Double-clicking the following field runs the PrintEnvelope macro.

Field:

Double-click { MACROBUTTON PrintEnvelope Button image} to print an envelope for this letter.

Result:

Double-click Button imageto print an envelope for this letter.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.