Writing an Outlook Macro
A macro is any public subroutine in a code module. A function or a private subroutine cannot be a macro, and a macro cannot be located in a class or form module.
To create a new macro
In Outlook, on the Developer tab of the Microsoft Office Fluent ribbon, click Visual Basic.
In the Project window, double-click the module you want to contain the macro.
On the Insert menu, click Procedure.
In the Name box, type a name for the macro. The name cannot contain spaces.
Click OK. The template for the macro subroutine appears in the code module window.
Type the code you want to run in the body of the subroutine.
For more information about using the Visual Basic Editor, see the Visual Basic Editor Help. Once you've created a macro, you can create a menu item or toolbar button that will run the macro when you click it.
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.