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

  1. In Outlook, point to Macro on the Tools menu, and then click Visual Basic Editor.

  2. In the Project window, double-click the module you want to contain the macro.

  3. On the Insert menu, click Procedure.

  4. In the Name box, type a name for the macro. The name cannot contain spaces.

  5. Click OK.

    The template for the macro subroutine appears in the code module window.

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