Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Outlook VBA macros let you automate repetitive tasks such as processing selected messages, creating reports, or responding to application events. The steps below apply to classic Outlook for Windows, including Outlook for Microsoft 365, Outlook 2024, Outlook 2021, Outlook 2019, and Outlook 2016.

They do not apply to new Outlook for Windows or Outlook for Mac. Those versions do not support Outlook VBA macros.

Before you start: check your Outlook version

VBA macros require classic Outlook. If you see a Developer tab, Visual Basic, or the classic Outlook ribbon, you are probably using the correct application.

New Outlook for Windows has a different interface and does not support VBA macros or the Developer tab. Outlook for Mac also does not support Outlook VBA macros. On some newer Windows computers, only new Outlook may be installed. In that case, install classic Outlook separately before following these instructions.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
  • All-day Comfort: The design of this standard keyboard creates a comfortable typing experience thanks to the deep-profile keys and full-size standard layout with F-keys and number pad
  • Easy to Set-up and Use: Set-up couldn't be easier, you simply plug in this corded keyboard via USB on your desktop or laptop and start using right away without any software installation
  • Compatibility: This full-size keyboard is compatible with Windows 7, 8, 10 or later, plus it's a reliable and durable partner for your desk at home, or at work
  • Spill-proof: This durable keyboard features a spill-resistant design (1), anti-fade keys and sturdy tilt legs with adjustable height, meaning this keyboard is built to last
  • Plastic parts in K120 include 51% certified post-consumer recycled plastic*

1. Show the Developer tab

The Developer tab is hidden by default in classic Outlook.

  1. Open Outlook.
  2. Select File.
  3. Select Options.
  4. Choose Customize Ribbon.
  5. Under Main Tabs, select the Developer check box.
  6. Select OK.

The Developer tab should now appear in the Outlook ribbon. If the option is missing, confirm that you are not using new Outlook.

2. Create a basic Outlook macro

The quickest way to create a macro is through the Macro dialog.

  1. Select the Developer tab.
  2. In the Code group, select Macros.
  3. Enter a name in the Macro name box. For example, enter HelloOutlook.
  4. Select Create.

Outlook opens the Visual Basic for Applications editor and creates a procedure template. Replace the template with this test macro:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Public Sub HelloOutlook()
MsgBox “Hello from Outlook”
End Sub

Macro names cannot contain spaces. Use letters, numbers, and underscores, and do not begin the name with a number. Examples include ProcessSelectedMail, Archive_Old_Messages, and SendDailyReport.

3. Put a manually run macro in a standard module

A macro that you intend to start yourself from the Macros dialog should be a Public Sub in a standard code module. It should not normally be placed in ThisOutlookSession, a class module, or a form module.

To create a standard module:

  1. In Outlook, select Developer > Visual Basic.
  2. In the Visual Basic Editor, locate the Outlook VBA project in Project Explorer.
  3. Select Insert > Module.
  4. Paste or type your procedure in the new module.

For example:

Public Sub ShowMessage()
MsgBox “This macro is running.”
End Sub

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Logitech MK270 Full Size Wireless Keyboard and Mouse Combo - Black
  • Reliable Plug and Play: The USB receiver provides a reliable wireless connection up to 33 ft (1), so you can forget about drop-outs and delays and you can take it wherever you use your computer
  • Type in Comfort: The design of this keyboard creates a comfortable typing experience thanks to the low-profile, quiet keys and standard layout with full-size F-keys, number pad, and arrow keys
  • Durable and Resilient: This full-size wireless keyboard features a spill-resistant design (2), durable keys and sturdy tilt legs with adjustable height
  • Long Battery Life: MK270 combo features a 36-month keyboard and 12-month mouse battery life (3), along with on/off switches allowing you to go months without the hassle of changing batteries
  • Easy to Use: This wireless keyboard and mouse combo features 8 multimedia hotkeys for instant access to the Internet, email, play/pause, and volume so you can easily check out your favorite sites

Only public subroutines in suitable code modules are treated as normal Outlook macros. A Function, a Private Sub, or a procedure in a class or form module may not appear in the Macro dialog.

4. Save the VBA project

Save your work in the Visual Basic Editor, or close Outlook and save when prompted.

Unlike Word or Excel, Outlook does not store its VBA code inside a document or workbook. Outlook normally stores the project in:

%AppData%\Microsoft\Outlook

The project file is named:

VbaProject.otm

Outlook supports one VBA project at a time. Because the project is stored locally, your macro will not automatically appear on another computer when you sign in to the same Microsoft account.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Run the macro

  1. Select Developer.
  2. In the Code group, select Macros.
  3. Select the macro under Macro name.
  4. Select Run.

For the sample macro, Outlook displays a message box containing “This macro is running.”

The Macro dialog also provides these useful commands:

Command What it does
Run Runs the selected macro.
Step Into Starts the macro in the VBA editor and executes it one line at a time.
Edit Opens the selected procedure in the VBA editor.
Create Creates a new macro.
Delete Removes the selected macro.
Cancel Closes the dialog without running a macro.

6. Configure Outlook macro security

Outlook may block macros depending on its Trust Center settings.

  1. Select File > Options.
  2. Select Trust Center.
  3. Select Trust Center Settings.
  4. Select Macro Settings.

Common options include:

  • Disable all macros without notification
  • Disable all macros with notification
  • Disable all macros except digitally signed macros
  • Enable all macros

For a personal macro, Disable all macros with notification is generally the safer choice. It prevents macros from running silently while allowing you to recognize and permit trusted code when appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Amazon Basics Wired QWERTY Keyboard, Works with Windows, Plug and Play, Easy to Use with Media Control, Full-Sized, Black
  • KEYBOARD: The keyboard works for Windows with hot keys that enable easy access to Media, My Computer, Mute, Volume up/down, and Calculator
  • EASY SETUP: Experience simple installation with the USB wired connection
  • VERSATILE COMPATIBILITY: This keyboard is designed to work with multiple Windows versions, including Vista, 7, 8, 10 offering broad compatibility across devices.
  • SLEEK DESIGN: The elegant black color of the wired keyboard complements your tech and decor, adding a stylish and cohesive look to any setup without sacrificing function.
  • FULL-SIZED CONVENIENCE: The standard QWERTY layout of this keyboard set offers a familiar typing experience, ideal for both professional tasks and personal use.

Enable all macros is not a general troubleshooting fix. It can allow potentially dangerous code to run without confirmation. Also note that macro settings are application-specific: changing the setting in Excel does not change Outlook’s setting.

If the controls are unavailable or your changes do not persist, your organization may be enforcing macro security through policy. Contact your administrator rather than attempting to bypass the policy.

7. Add the macro to the Quick Access Toolbar

You can run a frequently used macro without opening the Developer tab each time.

  1. Select File > Options.
  2. Select Quick Access Toolbar.
  3. In Choose commands from, select Macros.
  4. Select your macro.
  5. Select Add.
  6. Optionally select Modify to choose an icon and display name.
  7. Select OK.

The macro button will appear on the Quick Access Toolbar in Outlook.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

8. Add the macro to the Outlook ribbon

For a more visible command, add the macro to a custom ribbon group.

  1. Open File > Options.
  2. Select Customize Ribbon.
  3. Select an existing tab, or select New Tab.
  4. Select New Group if you need a dedicated group for macros.
  5. Under Choose commands from, select Macros.
  6. Select the macro and choose Add.
  7. Select Rename if you want to change its display name or icon.
  8. Select OK.

Ribbon customizations are application-specific. A macro button added to Outlook will not automatically appear in Word or Excel.

9. Create an event-driven Outlook macro

Not every macro is launched manually. Event procedures run when something happens in Outlook, such as the application starting or new mail arriving.

Application-level event code belongs in ThisOutlookSession, not in a standard module. To create a startup event:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
Logitech MX Keys S Wireless Keyboard Low Profile Fluid Precise - Graphite
  • Fluid Typing Experience: Laptop-like profile with spherically-dished keys shaped for your fingertips delivers a fast, fluid, precise and quieter typing experience
  • Automate Repetitive Tasks: Easily create and share time-saving Smart Actions shortcuts to perform multiple actions with a single keystroke with the Logi Options+ app (1)
  • Smarter Illumination: Backlit keyboard keys light up as your hands approach and adapt to the environment; Now with more lighting customizations on Logi Options+ (1)
  • More Comfort, Deeper Focus: Work for longer with a solid build, low-profile design and an optimum keyboard angle that is better for your wrist posture
  • Multi-Device, Multi OS Bluetooth Keyboard: Pair with up to 3 devices on nearly any operating system (Windows, macOS, Linux, Googlebook OS) via Bluetooth Low Energy or included Logi Bolt USB receiver (2)
  1. Select Developer > Visual Basic.
  2. In Project Explorer, double-click ThisOutlookSession.
  3. In the left object list above the code window, select Application.
  4. In the right procedure list, select Startup.
  5. Enter the event code.

Private Sub Application_Startup()
MsgBox “Outlook has started.”
End Sub

Save the project and restart Outlook to test an application startup event. This procedure normally does not appear in the regular Macro dialog because it is a private event handler triggered by Outlook.

Events for other Outlook objects require an object variable declared with WithEvents, along with initialization code. They are more involved than a manually run Public Sub.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

The Developer tab is missing

Check File > Options > Customize Ribbon and enable Developer. If the check box is not available, you may be using new Outlook or Outlook for Mac, neither of which supports Outlook VBA macros.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Macros command or Create button is missing

These commands are available in classic Outlook. They are not available in new Outlook. Switch to classic Outlook if it is installed, or install it separately.

My macro does not appear in the Macro dialog

Check each of these points:

  • The code is in a standard module.
  • The procedure is declared Public.
  • It is a Sub, not a Function.
  • The procedure is not inside ThisOutlookSession, a class module, or a form module.
  • The name contains no spaces.
  • The code has no syntax errors.
  • The VBA project is saved and allowed by macro-security settings.

The code runs from the editor but not from the Macro dialog

The procedure probably is not a listed macro. Move manually run code to a standard module and declare it as a Public Sub.

The event macro never runs

Confirm that the event procedure is in ThisOutlookSession, that its name and signature are correct, and that the project is saved. Restart Outlook when testing startup or application-level events. Macro security can also prevent the code from running.

The VBA code turns red

Red text usually indicates a syntax problem. Look for an unmatched quotation mark, invalid characters, a malformed declaration, or a missing End Sub. Do not delete ThisOutlookSession simply because the editor highlights code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Wireless Keyboard and Mouse Combo Silent for Office and Home(Avocado Green)
  • 【Lag-free & Efficient】Stable and reliable connection of wireless keyboard and mouse is up to 10m(33ft). This combo share a nano USB receiver, no need to take up additional USB ports (Also the wireless keyboard and mouse can also be used separately). Plug and play, no software needed,convenient and efficient.
  • 【Quiet & Type in Comfort】Wireless keyboard come with adjustable height tilt legs to increase comfort and prevent your wrists injury when typing for a long time.Our wireless keyboard adopts a silent structure. Soft membrane keys provide a quiet and comfortable typing experience.The wireless mouse is quiet without any clicking sound also.So whether at home or in the office, you can use this combo as you please without worrying about disturbing others.
  • 【Full Size Keyboard】This keyboard saves desktop space while retaining its full size.The full size wireless keyboard with numeric keypad and 12 multimedia shortcut keys, such as play/ pause, volume increase and decrease, and search, to help you improve work efficiency.
  • 【Auto Power Saving Function】Wireless keyboard and mouse have a smart auto-sleep mode to save power for long battery life. They will enter sleep mode after stop using a while(Refer to the instructions for details). Unplug the receiver or after the PC shutdown, they will enter sleep mode too.You can press any keys to wake. (battery life may vary based on user and computing conditions)
  • 【Comfortable Optical Mouse】This silent wireless mice provides 3 adjustable DPI (800/1200/1600) to meet your different needs in terms of sensitivity.The compact lightweight design of wireless mouse and a hand-friendly contoured shape for all-day comfort, and smooth, precise tracking. Very suitable for office and daily use.

Outlook displays security prompts

Some automation code can trigger Outlook Object Model Guard warnings, especially when it accesses address information, reads Outlook data in a sensitive context, or sends messages programmatically. Do not disable all programmatic-access warnings as a routine fix. Review the code and use an approved, controlled configuration if your organization requires automation.

The macro disappeared after moving to another computer

Back up or transfer the Outlook VBA project file, VbaProject.otm, from %AppData%\Microsoft\Outlook, or export and import individual VBA modules. Outlook VBA was designed primarily as a personal macro-development environment, not as a packaged distribution format. Always keep a separate backup of important code.

FAQ

Can I create a VBA macro in new Outlook for Windows?

No. VBA macros are supported in classic Outlook for Windows, but not in new Outlook for Windows.

Can I create an Outlook VBA macro on a Mac?

No. Outlook for Mac does not support Outlook VBA macros.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Where should I put an Outlook macro?

Put a manually run macro in a standard module as a Public Sub. Put application event procedures, such as Application_Startup, in ThisOutlookSession.

Where does Outlook save macros?

Outlook normally saves its VBA project in %AppData%\Microsoft\Outlook\VbaProject.otm.

Why is my macro missing from the Macros dialog?

The procedure may be private, a Function instead of a Sub, or located in ThisOutlookSession, a class module, or a form module. Move it to a standard module and declare it as Public Sub.

Should I enable all Outlook macros?

No. Enabling all macros is potentially unsafe. Use a notification-based setting where possible and run only code you trust.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

To create an Outlook VBA macro, use classic Outlook for Windows, enable Developer, choose Developer > Macros > Create, and place a Public Sub in a standard module. Save the project, configure macro security carefully, and run it from the Macros dialog or a custom toolbar button. Use ThisOutlookSession only for Outlook event procedures.

Quick Recap

SaleBestseller No. 1
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Logitech K120 Full Size Wired Keyboard USB Plug-and-Play Windows - Black
Plastic parts in K120 include 51% certified post-consumer recycled plastic*; Product carbon footprint: 4.02 kg CO2e
$12.34
Bestseller No. 3

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.