O'Reilly logo

Professional Outlook® 2007 Programming by Ken Slovak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Outlook VBA

In this chapter, you learn more about working with the Outlook VBA project, and how to use it to create macros and to prototype code destined for use in COM addins and standalone projects.

The code in this chapter uses the intrinsic ThisOutlookSession class module, custom classes, and VBA UserForms for user input and data display to create macros that you can run on demand as well as code that runs automatically when Outlook starts or in response to specific Outlook events. These types of uses are common not only for VBA macro code but also in almost every Outlook application you write, including COM addins and standalone projects.

The Outlook VBA Project

Unlike Office applications such as Word, where the VBA project is document oriented, Outlook code is oriented towards the application. This orientation is similar to the orientation of COM addins and standalone projects, and makes Outlook VBA especially useful as a prototyping tool. The VBA project is also used for creating two classes of macros, macros that run automatically and those that are run on demand by the user, which you learn about in this chapter.

The Project File

Outlook has one global VBA project file, stored in the file system as VBAProject.OTM. This file is usually located in the C:\Documents and Settings\<windows logon>\Application Data\Microsoft\Outlook folder, where <windows logon> is the current user logon name for Windows. All Outlook VBA code is contained in this project file. This is unlike ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required