How to Run VBA Code in Your Outlook

At times you may wish to utilize VBA code in Outlook to achieve more functions. Yet, you do not know how to run VBA code in your Outlook. Thus, this article will expose the detailed steps to you.

Thereinafter, we will take Outlook 2010 version as an example and show you the elaborate steps, ranging from modifying macro security settings to running VBA code. Now, read on to get them.

Step 1: Enable “Developer” Tab

  1. First of all, after launching Outlook, access “File” menu.Access File Menu
  2. Then, in “File” menu, select and click on “Options”.Select Options in File Menu
  3. Next, in the popup “Outlook Options” window, switch to “Customize Ribbon”.
  4. Later, on the right side, you can find out and enable the “Developer” tab.Enable the “Developer” Tab
  5. Lastly, click “OK”.

Step 2: Check Macro Security Settings

  1. After returning to Outlook main window, you can access “Developer” ribbon.
  2. Then, click on the “Macro Security” button.Open Macro Security
  3. In the subsequent screen, you should select “Notifications for all macros” and hit “OK” button.Change Macro Security

Step 3: Access Outlook VBA Editor

To run VBA code, you have to access the VBA editor firstly, which can be achieved by the following 2 means:

  1. In Outlook, under the “Developer” tab, click on the “Visual Basic” button.Access VBA Editor by "Visual Basic" Button
  2. Or you can directly press “Alt + F11” key buttons.

Step 4: Add VBA Code

  1. In VBA editor, namely “Microsoft Visual Basic for Applications” window, you need to expand the “Microsoft Outlook Objects” folder on left side
  2. Then, double click on the “ThisOutlookSession” project to open it.Open “ThisOutlookSession” Project
  3. Subsequently, you can copy and paste your VBA code into the white editing pane of this project.Paste VBA Code
  4. Optionally, you can copy the VBA code into a module.
  • Click “Insert” button in the menu bar.
  • Choose “Module” from the drop down list.Insert New Module
  • Then, a new module will display. Now you can copy code into the module as usual.New Module

Note: In general, you can paste the code into either “ThisOutlookSession” or a module. But, the VBA code involving events, like “Application_Start”, must be put in “ThisOutlookSession”.

Step 5: Run VBA Code

After adding the macro, you can run it. In the macro window, you can press “F5” key button or click on the “Run” button in the toolbar.Run VBA Code

Note: For the VBA code involving events, like “Application_Start”, you ought to restart your outlook to activate it.

Optional Step: Add Macro to Quick Access Toolbar or Ribbon

If you would like to run macro in the main Outlook window instead of in the VBA editor, you can add the macro to Quick Access Toolbar or ribbon. Here we’ll take Quick Access Toolbar as an instance.

  1. First off, access “Outlook Options” by following the operations shown in Step 1, in which you can shift to “Quick Access Toolbar” tab.
  2. Next, select “Macros” from the “Choose commands from”.
  3. Then, in the macro list, choose a macro.
  4. After that, click “Add >>” button in center.
  5. Finally, click “OK”.Add Macro to Quick Access Toolbar
  6. Since then, to run this macro, you can simply click the macro button in Quick Access Toolbar.Run Macro through Quick Access Toolbar

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf recovery and outlook repair software products. For more information visit www.datanumen.com

2 Comments

  1. Comment by Vitanoria Hair:

    Wow! After all I got a webpage from where I can truly obtain useful facts regarding
    my study and knowledge.

  2. Comment by what are macros bodybuilding:

    I enjoy, result iin I found just what I used to be taking a look for.
    You’ve ended my four day lengthy hunt!God Bless
    you man. Have a great day. Bye