Chapter 22. Writing Macros and Visual Basic Code in Outlook

IN THIS CHAPTER

  • Understanding macros

  • Using the Macros dialog box

  • Working with the VBA Editor

  • Security and macros

  • Assigning macros to menus and toolbars

  • Debugging macros

A macro is a sequence of program commands and keyboard input that has been saved. At any time, you can play the macro back and the result is exactly the same as if you had entered the same commands and input using the keyboard and mouse. Macros are terrific for automatic tasks that you perform regularly, and they can also help prevent errors.

Understanding Macros

Outlook (along with other Office programs) has a built-in programming language called Visual Basic for Applications, or VBA for short, that lets you write programs, called macros, to automate program operations. A macro may do something as simple as inserting a signature into an email message, or something as complex as sorting all incoming email into folders based on the sender. Macros offer two important benefits:

  • They save time. A sequence of actions that might take you a minute or more to perform manually can be executed essentially instantly with a macro.

  • They prevent errors. A properly written macro does not make mistakes. It performs the exact same sequence of commands each time it is run without typos or other errors.

You are not limited to using macros that you write. You may be able to get useful macros from your friends and colleagues, and some commercial products that add functionality to Outlook ...

Get Microsoft® Outlook® 2007 Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.