Create a button for a macro

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

The built-in way to execute a macro (in Outlook 97-2007) is by using the Tools-> Macro-> Macros… menu in the main Outlook window. 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.

In Outlook 2003 and previous, with Outlook set as the email editor, you can use the same method as above. However, when you use Word as the e-mail editor, then you’ll have to create the macro in Word but you can still use this guide to create a button for it in the same way.

In Outlook 2007, Outlook 2010 and Outlook 2013, the Developer tab on the Ribbon, which holds the Macros menu for opened items, is disabled by default.

To enable it for 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.

To enable it for Outlook 2010 and Outlook 2013:

  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.

Tip!
The keyboard shortcut for bringing up the Macros dialog box is ALT+F8.

Create a button on a Toolbar

Adding a button to a toolbar can be done in Outlook 2003 and previous or in the main window of Outlook 2007.

As stated earlier, note that when you are using Outlook 2003 or earlier and are using Word as the e-mail editor, the macro has to be created in Word when you want to have it available in the compose message window. Other than that, the instructions to create the macro button are exactly the same.

  1. First put the Toolbar in Edit Mode:
    View-> Toolbars-> Customize…
  2. Verify that the Commands tab is selected.
  3. In the Categories list on the right, select Macros.
    The Commands list on the right will now display all you macros
  4. Drag and drop the macro that you wish to create a button for to the location on the toolbar where you want it.
  5. To modify the name and icon, right click the icon on the Toolbar;
    • You can edit the name to something more meaningful.
      If you want to use an ALT+key shortcut for the button, place an & for the letter that you want to use.
      For instance, let’s assume you call it “My Button” and want to use the ALT+Y combination.
      You’d then write “M&y Button”
    • You can change the button image via the Change Button Image selector or free hand via the Edit Button Image… dialog.
      In the free hand editor, you can actually paste another image or icon you have copied from via CTRL+V.
    • You can also disable the text or button or image if you don’t like to see it.
  6. Close the Customize dialog to leave Edit Mode of your Toolbars and use your button.

More about customizing your Toolbar can be found in this guide.

Two macro buttons on the Toolbar
Two customized macro icons on the Toolbar (click here and here for their functions)

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 on 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.

  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 QAT and choose More Commands…
    or
    Click on the Office logo in the left top, choose Editor Options and select the Customize section.
  3. In the drop down list “Choose commands from” select: Macros.
    The list below will now show you all your macros.
  4. Select the macro that you wish to create a button for and press the Add >> button.
  5. To modify the name and icon press the Modify… button.
    • Unlike a toolbar button, you cannot assign your ALT+key combination via letters.
      Use the up and down button next to command list to move your macro up and down.
      When you close the Editor 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.
    • Unlike a toolbar button, you cannot paste your own icon or freely edit it. However, the icon list is longer and the icons are of a higher quality when compared to previous versions of Outlook.
  6. Close the Editor Options dialog to return to your item window and use your button.

macro button on the QAT
A custom macro button on the QAT. (click here for its function)

Create a button on the Ribbon

In Outlook 2007, there is no native option to customize the Ribbon and thus it is not possible to add your own custom button to the Ribbon to execute your macro. However, it is possible via an add-in called Ribbon Customizer.

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.

In Outlook 2010 and Outlook 2013, things have been made a lot easier as it allows you to manually customize the Ribbon as well.

  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”.
    or
    Right click any tab and choose “Customize the Ribbon”.
    You’ll find the current tab already highlighted and selected.
  4. 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.
  5. From the dropdown list “Choose commands from:” select: Macros.
    The list below will now show you all your macros.
  6. Select the macro that you wish to create a button for and press the Add >> button.
  7. To modify the name and icon press the Modify… button.
    • Unlike a toolbar button, you cannot assign your ALT+key combination via letters.
      When you close the Editor 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.
    • Unlike a toolbar button, you cannot paste your own icon or freely edit it. However, the icon list is longer and the icons are of a higher quality when compared to previous versions of Outlook.
  8. Close the Editor Options dialog to return to your item window and use your button.

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

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, 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.

For Outlook 2003 and previous, there is no supported way to customize the context menu. However, there are some hacks and workarounds for this where you’d need to listen to the CommandBars.OnUpdate Event and get the command bar via Application.CommandBars["Context Menu"], a code sample on how to do it is listed here.