How to create a button for a macro

Total Views : 186
Zoom In Zoom Out Read Later Print

When adding some custom functionality to Outlook or to perform repetitive tasks more quickly, it can be achieved by creating a macro in the VBA Editor of Outlook. However, access to the option to execute a macro is a bit boring and difficult in the options and dialog of Outlook or sometimes completely hidden by default.

This guide will introduce how you can create a button for your macro in the Outlook.

Developer Tab

Developer Button This is an built-in method to execute macros on the Ribbon. This tab contains a Macros button which allows you to execute a macro directly. However, this tab is disabled by default, so we'll need to enable it first before we can use this method to run macros.

In Outlook 2007:

1. Open a message or create a new one.
2. Click on the Office logo in the left top and choose Editor Options.
3. In the Popular section, enable the option: Show Developer tab in the Ribbon.
4. Press OK to close the open dialog.

Note: From the main Outlook 2007 window, You can execute macros via Tools-> Macro-> Macros.

In Outlook 2010 / 2013 / 2016 / 2019 and Office 365 :

1. Press the File button next to the Home tab and choose Options.
2. Select the section Customize Ribbon.
3. In the right pane, enable the selection field before Developer.

4. Press OK to close the open dialog.

Once you have enabled the Developer tab, select the tab and press the Macros button. This will launch a dialog with all your macros to choose from. Select the one you want and then press the Run button to execute it.

Quick Tip: The keyboard shortcut to bring up the Macros dialog box is ALT+F8, even when the Developer tab isn’t enabled.

Create a button on the Quick Access Toolbar

The Quick Access Toolbar is the first line of icons that appears above the Ribbon and is placed within the Title Bar of the window. The Quick Access Toolbar can be placed below the Ribbon as well, if you want it to be there.

The Quick Access Toolbar is different for each type of Outlook window, a different one for composing a message and reading a message, a separate one for Contacts, a separate one for Appointments etc.

1. Open the item window for which you’d like to add the macro button to.
2. Click the little down arrow on the right side of the Quick Access Toolbar and choose More Commands.

Alternative methods:

In Outlook 2007

Click on the Office logo in the left top, choose Editor Options and select the Customise section.

In Outlook 2010 / 2013 / 2016 / 2019 / Office 365

File-> Options-> Quick Access Toolbar

3. In the drop down list Choose commands from select: Macros.

4.  The list below will now show you all your macros.
5. Select the macro that you wish to create a button for and press the Add >> button.

6. Use the up and down button next to command list to move your macro up and down.
7. To modify the name and icon press the Modify button. 

8. Close the Options dialog to return to your item window and use your button.
9. A custom macro button on the Quick Access Toolbar. click on it to run you selected macros.

Quick Tip : When you close the Options dialog and press and release the ALT button on your keyboard, you’ll see a number appear above your macro button which you can type on your keyboard to activate your macro. This keyboard shortcut makes it even quicker to execute your macro. For our newly created macro in previous steps we can use ALT+4 to run it.

Create a button on the Ribbon

Instead of adding a macro button on the Quick Access Toolbar, it might make more sense to add it to an already existing tab or to create your own tab which contains you macros and / or other commands.

1. Open the item window where you’d like to add the macro button to.
2. Select the tab where you’d like to add the macro button to.
3. Click the File button next to the Home tab and choose Options. Here, select the section Customize Ribbon.

Alternative method: Right click any tab and choose Customize the Ribbon.

4. You’ll find the current tab already highlighted and selected.
5. Create a New Group or a New Tab to place your custom button in. You cannot add your button to an existing group.

6. You can use the Rename button to give your group and / or tab a nice name.
7. From the drop-down list Choose commands from: select: Macros.
8.  The list below will now show you all your macros.
9. Select the macro that you wish to create a button for and press the Add >> button.

10. To modify the name and icon press the Modify… button.
11. Close the Editor Options dialog to return to your item window and use your button.

Quick Tip: When you close the Options dialog and press and release the ALT button on your keyboard, you’ll see a number appear above your macro button which you can type on your keyboard to activate your macro. This keyboard shortcut makes it even quicker to execute your macro.

Create a button in the right click menu

For now there are no options available within Outlook that will allow you to customise the Context menu. If you are looking for a way to programmatically add your own button using a COM Add-In, please see the Developers Area for more information.

Additional information

When you are getting a macro security warning when executing your macro, you should not lower macro security settings. Instead, sign your macro code with self-cert. This tool is included by default in Office and the process is just as simple and nearly as quick as lowering your security settings, but benefit that you keep your security level in Outlook.

Developers Area

This is intended for developers who which to programmatically modify the Ribbon, toolbars and context menus in Outlook. The methods mentioned and links provided requires knowledge on how to create a COM Add-In for Outlook. If you decide you want to create your VBA solution as a COM Add-In instead, the use of Visual Studio with support for Microsoft Office (VSTO) would be recommended.

Customize the Ribbon programmatically

In Outlook 2007, it is only possible to customize the Ribbon via a COM Add-In. There is no way to do this via VBA. Some additional information about customizing the Ribbon can also be found here.

Customize the Context Menu programmatically

Adding a custom button on the right click menu (context menu) is only possible via a COM Add-In as well. More information about that can be found here. More specifically, you’ll need to use the Application.ItemContextMenuDisplay Event which was first introduced in Outlook 2007.

See More

Latest Photos