Sometimes, you may want to apply a button to run a specific macro code within a Word document. However, how can you accomplish this task in a Word file?
Applying a Button to Run a Specific Macro Code in a Word Document
The following steps can help you achieve this task within a Word document. Please follow these instructions:
- Click where you want to place the button, then press Ctrl + F9 to insert a pair of curly braces. Enter the text below inside the curly braces, as shown in the screenshot:
MACROBUTTON MacroName Double-click to run Macro
Note: Replace “MacroName” with the name of the macro in your Word file that you want to run when the button is clicked. Please customize it accordingly.
- Right-click on the field code and select “Toggle Field Codes” from the context menu, as shown in the screenshot:
- You can then format the field text with border and shading to turn it into a button. Select the field text, then choose “Borders and Shading” from the Home tab, as shown in the screenshot:
- In the Borders and Shading dialog, specify the border style and shadow color according to your preference, as shown in the screenshot:
- Click OK, and the field text is now formatted as a button. Now, when you double-click on this button, your specific macro code will be activated immediately, as shown in the screenshot: