Click the "Add" button to add the button to the QAT.Ģ2. Click on one of the custom macro buttons that you want to add to the QAT.Ģ1. Click on the box below where it says “Choose commands from” and then click on the name of the custom Ribbon tab that you created in step 7.Ģ0. Right-click on the Ribbon or QAT and select "Customize Quick Access Toolbar".ġ9. Save the changes and close the Visual Basic Editor.ġ8. Note that you have to include the Module name ("NewMacros" in the example) followed by a dot and then the macro name for the macro buttons to function.ġ7. Sub ButtonOnAction(Control As IRibbonControl)Įnter each buttons id (obtained from the XML code) after the Case statement and enter the name of the macro that you want the button to run on the next line.
#INSERT MACRO BUTTON WORD CODE#
In the code pane (below where it says "General"), add the following VBA code: Select Insert > Module from the menu and rename the module "RBX" by typing the new name in the box next to (Name) in the Properties pane.ġ6. In the Project pane, click on the Project that has the document name next to it.ġ4. Press Alt-F11 to open the Visual Basic Editor.ġ3. Click the Save button (or press Ctrl-S) and exit the Custom UI Editor.ġ2. Click on the "Validate" button to verify that the code doesn't contain errors.ġ0. Use the buttons "label" attribute to specify the text that you want to be displayed when the mouse pointer hovers over the button.ĩ. Enter the name (id) of the icon image (as it appears next to the icon image in the Custom UI Editor) that you want to use for each button in the buttons "image" attribute. Use the groups “label” attribute to provide a name for the group.Ĩ. You can type in a name for the custom tab in the "label" attribute that comes after “tab id”. This custom Ribbon tab will be used to "store" the custom buttons/images thatĪre going to be placed on the QAT. The above code creates a custom tab on the Ribbon with a group containing three buttons with custom icons. In the right-hand pane, add the following XML code: The following types of images can be used for button icons: PNG, JPG, BMP, WMF, ICO and GIF (my attempts to use ICO images have been unsuccessful).ħ. The ideal size for button images thatĪre going to be added to the QAT (Quick Access Toolbar) is 16 pixels x 16 pixels. Click on the "Insert icons" button on the Custom UI Editor toolbar to add the images that you want to use on the macro buttons. Click Insert on the menu and select "Office 2010 Custom UI Part" or "Office 2007 Custom UI Part" (choose the one that corresponds to the Office version that you'reĦ. Open the Word document that you created in step one.ĥ.
#INSERT MACRO BUTTON WORD DOWNLOAD#
Open the Custom UI Editor (see download link at the end of this post).Ĥ. Open a new document in Word and save it as a Word macro-enabled document (.docm).ģ. Type the text you want displayed, or insert a graphic to be used as a button.** Important: never have the document that you're working on open in the Custom UI Editor and Word at the same time! This can and will cause problems, such as losing the custom XML code and havingġ.Between the field brackets, type MacroButton, then the name of the command or macro you want the button to execute.Position the insertion point where you want the button to appear.
To assign a command or macro to a button, and insert that button in your text, follow these steps: When a user double-clicks on the displayed text or graphic, then the macro or command defined by MacroName is executed. If you use a graphic instead of text, then the graphic is displayed. 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. 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.
This is all instituted through the use of a field code. 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. Word also allows you to add buttons within the text of you document. You already know you can assign a macro to a button (a tool) on your toolbar.