When adding some custom functionality to Outlook or to perform repetitive tasks more quickly, it often 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 buried in the options and dialogs of Outlook or sometimes completely hidden by default. This of course negatively affects the purpose of some macros; to be able to perform repetitive tasks more quickly.
This guide will introduce how you can create a button for your macro in the various screens of Outlook.
- Default Methods
- Create a button on the Quick Access Toolbar
- Create a button on the Ribbon
- Create a button in the right click menu
- Additional Information: Macro Security
- Developers Area
Developer tab
The built-in method to execute macros is via the Developer tab on the Ribbon. This tab contains a Macros button which allows you to execute a macro. However, this tab is disabled by default so we’ll have to enable it when you want to use this method.
- Press the File button next to the Home tab and choose Options.
- Select the section: Customize Ribbon.
- In the right pane, enable the selection field before “Developer”.
- Press OK to close the open dialog.
Once you have enabled the Developer tab, select the tab and press the Macros button. This will show a drop down list or launch a dialog with all your macros to choose from. Select the one you want and then press the Run button to execute it.
Tip!
The keyboard shortcut to bring up the Macros dialog box is ALT+F8.
This shortcut works even when the Developer tab isn’t enabled.
Create a button on the Quick Access Toolbar
The Quick Access Toolbar (QAT) is the line of icons that appears above the Ribbon and is placed within the Title Bar of the window. Optionally, the QAT can be placed below the Ribbon as well.
The QAT is different for each type of Outlook window. So this means that there is a different one for composing a message and reading a message, a separate one for Contacts, a separate one for Appointments etc… For an overview of which item windows exist in Outlook, see this blog post.
- Open the item window for which you’d like to add the macro button to.
- Press the File button next to the Home tab and choose Options.
- Select the section: Quick Access Toolbar
- In the drop down list “Choose commands from” select: Macros. The list below will now show you all your macros.
- Select the macro that you wish to create a button for and press the Add >> button.
- Use the up and down button next to command list to move your macro up and down.
- To modify the name and icon press the Modify… button.
- When using Outlook as part of Microsoft 365, verify that the option “Show Quick Access Toolbar” is enabled.
- Close the Options dialog to return to your item window and use your button.
A custom macro button on the QAT. (click here for its function)
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 on the Ribbon
Instead of adding a macro button on the QAT, it might make more sense to add it to an already existing tab of the Ribbon or to create a tab of your own which contains you macros and/or other favorite commands.
- Open the item window where you’d like to add the macro button to.
- Select the tab where you’d like to add the macro button to.
- 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”.
You’ll find the current tab already highlighted and selected.
- Right click any tab and choose “Customize the Ribbon”.
- Create a New Group or even a New Tab to place your custom button in. You cannot add your button to an existing group.
You can use the Rename… button to give your group and/or tab a nice name. - From the dropdown list “Choose commands from:” select: Macros.
The list below will now show you all your macros. - Select the macro that you wish to create a button for and press the Add >> button.
- To modify the name and icon press the Modify… button.
- Close the Editor Options dialog to return to your item window and use your button.
Tip!
When you close the Options dialog and press and release the ALT button on your keyboard, you’ll a letter above the tabs. Type the letters above your tab and then you’ll see letters above the the commands on the commands. Type the letter above your macro to activate your macro.
Create a button in the right click menu
There are no options available within Outlook that will allow you to customize the Context menu.
If you are looking for a way to programmatically add your own button via a COM Add-In, please see the Developers Area for more information.
Additional information: Macro Security
When you are getting a macro security warning when trying to execute your macro, you should not lower macro security settings. Instead, sign your macro code with SelfCert.
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 with the added benefit that you keep your security level in Outlook right where it should be.
Developers Area
This section goes beyond what you can do via the Outlook interface and 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
As mentioned earlier, 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.
When you’ve created an Office Store web add-in, adding buttons for it to the Ribbon is described 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.