Adding Macros to the Ribbon Bar

When you have macros that you use often, you may want to add them to the Ribbon Bar for easy access.

Add a Saved Macro to the Quick Access Toolbar

1. Create a new macro: Select the Home tab. Click the New arrow, and from the drop-down list select Macro to display a new macro.

2. After Sub Main, before End Sub, insert the code to attach a macro to the Quick Access toolbar, the path to where the macro resides, and the name of the macro. In the following image, a comment was added to describe what the macro will do.

3. Run the macro: Select the Debug tab, and in the Run group, click the green Run arrow. The macro specified in the new macro will be added to the Quick Access toolbar. Click on it to run it.

Remove a macro from the Quick Access toolbar. To remove a macro, create a new macro. After Sub Main, before End Sub, enter the following code:

Application.RibbonBarSettings.QuickAccess.RemoveMacro(C:\File\Path\NameOfYourMacro.svb")

Run the new macro to remove the specified macro from the Quick Access toolbar.

Add a Saved Macro to the Macro Menu

1. The Macro menu is located on the Home tab in the Tools group. To attach a macro to this menu, first create a new macro.

2. After Sub Main, before End Sub, enter the following code:

Application.RibbonBarSettings.AddMacro(C:\File\Path\NameOfYourMacro.svb")

3. Run the macro. The macro specified in the new macro will be added to the Macro menu. Select it to run it.

Note: You can save a newly created macro to the Macro menu. Create a new macro. From the Macro menu, select Add Macro to Ribbon Bar. The Save As dialog box will be displayed, where you choose the location to save the macro and name the macro. Click OK, and this new macro will be added to the Macro menu.

Remove a macro from the Macro menu. To remove a macro, create a new macro. After Sub Main, before End Sub, enter the following code:

Application.RibbonBarSettings.RemoveMacro(C:\File\Path\NameOfYourMacro.svb")

Run the new macro to remove the specified macro from the Macro menu.

See also, Ribbon Bar and Customize Quick Access Toolbar.