O'Reilly logo

Microsoft® Outlook® 2007 Bible by Peter G. Aitken

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 23. Getting Started with VBA

IN THIS CHAPTER

  • Basic VBA syntax

  • Storing data—variables, arrays, and constants

  • VBA operators

  • Conditional and loop statements

  • Writing and calling procedures

VBA, or Visual Basic for Applications, is the programming language built in to the programs in the Microsoft Office suite, including Outlook. To be able write and edit Outlook macros, you must have a decent understanding of the VBA language. Fortunately, it is a fairly easy language, having been designed from the very beginning to be accessible not just to computer geeks but also to us ordinary mortals.

This chapter provides an introduction to the VBA language, giving you an overview of the most essential language elements. It is by no means a complete treatment of VBA—that would require an entire book in itself! With the information provided in this chapter, you can start writing useful macros. As your needs and interest dictate, you can find more information on VBA in the online help, books, and other sources.

Basic VBA Syntax

A VBA program, or macro, is made up of a series of VBA statements. Each statement is an instruction that tells Outlook to perform an action such as adding two numbers or opening an email message. Each statement is on its own line in the source code, although long lines can be split with a space followed by an underscore in order to make them easier to read in the editor. Thus, the following is treated as a single line of code:

ActiveWorkbook.CustomDocumentProperties.Add _ Name:="Part ...

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