When you talk about programming and Outlook, you have four basic options. You can use custom forms, use Outlook VBA, automate Outlook from other applications, or develop a COM add-in to work within Outlook. Custom forms are perfect for exchanging information with others in your organization. You can use custom forms to request specific data in defined formats. You can use VBScript behind Outlook forms to control the display or formatting of data within the Outlook forms, or to create new Outlook items from the custom forms. Outlook VBA is more feature-rich than Outlook custom forms. You can create VBA user forms as well as respond to a variety of application-level events. You can also create your own macros and assign them to toolbar buttons. The main limitation of Outlook VBA is that it's very difficult to share with other users. All Outlook VBA code is stored in a single file: VBAProject.otm. To share VBA code, you either have to completely replace the recipients' VBAProject.otm file, which deletes any code they might have created, send the code in a text file for them to copy into their VBAProject.otm file, or use a command-line switch. Outlook 2003 enables you to use a command-line switch to specify an alternative .OTM file. Starting Outlook with the following switch outlook.exe /altVBA c:\VBAFiles\NewVBA.otm tells Outlook to use the NewVBA.otm file located in c:\VBAFiles. Although this is a better solution than simply replacing another user's VBAProject.otm file, it still limits users to only one .OTM file at a time. The Outlook object model is fairly full featured. You can access the Outlook object model from a variety of other applications. Any application that supports VBA, including all the other Office programs, Project, Visio, and many other non-Microsoft programs, can also access the Outlook object model. Visual Basic, Visual C++, and all .NET programming languages also have the capability of automating Outlook through the Outlook object model. One of the ways you can use other applications with Outlook is to use Word or Excel to print reports that access Outlook data. Printing custom forms can be tricky at best and horrendously confusing at worst. Using Microsoft Word or Excel to output your Outlook data can be a relatively simple, yet powerful method of generating reports. The last mainstreammethod of programming Outlook is through a COM add-in. A COM add-in is a program, usually written in Visual Basic, Visual C++, or Visual Basic .NET. You can use COM add-ins to create toolbars, respond to application-level events, and interact with external data, such as that within a SQL Server database. COM add-ins aren't simple, but they can be very powerful. Many of the third-party add-ins for Outlook are implemented as COM add-ins. Using COM add-ins, you can also add pages to the Tools, Options dialog box within Outlook to set individual options for your COM add-in. This chapter provides a brief summary of automating other applications through Outlook, automating Outlook through other applications, and an overview of COM add-ins. A detailed explanation of COM add-ins is beyond the scope of this book, but there are many good books on Outlook development you can investigate to learn more about COM add-in development. In addition, several articles about writing COM add-ins are available on the Microsoft Developers Network (MSDN) Web site. |