26.1. Getting an Overview of the Outlook Object Model

Many people find Outlook harder to work with programmatically than other Office applications, so it's particularly helpful to look over the Outlook object model to see which objects Outlook uses and how they're related.

You can find Outlook object model maps by choosing Help Microsoft Visual Basic Help in Outlook's Visual Basic Editor (or by pressing F1). But this version of the maps lacks a left pane that adds a useful list of object links, and also lacks other functionality offered by MSDN online. So rather than taking the built-in Help system approach, I recommend that you instead go online to http://msdn2.microsoft.com/en-us/library/bb176619.aspx

If this URL doesn't display the Outlook object model maps (Microsoft has a habit of moving web pages around frequently), then follow these steps to find the Outlook object maps:

  1. Launch your browser.

  2. Type MSDN in the browser's search field.

    You should be directed to the main MSDN page:

    http://msdn2.microsoft.com/en-us/default.aspx

  3. In the Live Search field on the MSDN home page, type outlook object model map.

  4. In the list of links that results from this search, click the following link: Outlook Object Model Reference [Outlook 2007 Developer Reference].

Unlike the other Office 2007 applications we've looked at in previous chapters, Outlook provides five different object model maps (graphic diagrams of the hierarchies of objects). In the right pane of the Outlook Object Model Reference you'll see a set of five links to the maps. These maps collectively represent the object model. There are separate maps for the Application object, the Items object, the Navigation and Outlook Bars objects, the Rules object, and the Views object.

Click the link to the Application object model map, the most comprehensive of the five maps. You'll see the graphic relationship between objects in your Internet browser (see Figure 26.1).

Figure 26.1. The Outlook Object Model screen in the online MSDN Help system shows you how the Outlook objects are related to each other. This is the object model for Outlook 2007. You can click an object to see details about it.

When you look at the Outlook Object Model entry on your screen, you'll see that some of the boxes are shaded yellow, while the others are shaded blue. The yellow boxes are objects thatare organized into collections, and the blue objects are ones that do not have collections. Boxes with red stars display objects and collections that are new in Office 2007.

Click a box to see the Help screen for the object. Figure 26.2 shows the Help screen for the Inspectors collection, which contains details of the Inspector objects available in Outlook.

26.1.1. Understanding Where Outlook Stores VBA Items

As you've seen earlier in this book, Word and Excel let you store VBA projects either in a global location (the Normal.dotm template in Word or the Personal Macro Workbook in Excel) or in individual templates or document files, while PowerPoint lets you store VBA projects in presentation files and templates. Outlook, by contrast, doesn't let you store VBA projects in individual items (such as e-mail messages or contacts). Instead, Outlook uses a single VBA project called VbaProject.OTM, which is stored in the following folder:

C:UsersRichardAppDataRoamingMicrosoftOutlook

(Instead of Richard in this path, substitute your username.)

Figure 26.2. The Help screen for an individual object or collection includes a code example showing you one way to use the object or collection in your code.

26.1.2. Understanding Outlook's Creatable Objects and Main User Interface Items

The Application object represents the entire Outlook application, so you can access any Outlook object by going through the Application object. However, Outlook also exposes various creatable objects, allowing you to reach some of the objects in its object model without explicitly going through the Application object. These are the main creatable objects; you'll meet most of them in more detail later in this chapter and in the next chapter:

  • The Explorers collection contains an Explorer object for each window that displays the contents of a folder.

  • The Inspectors collection contains an Inspector object for each window that's open displaying an Outlook item.

  • The COMAddIns collection contains a COMAddIn object for each COM (Component Object Model) add-in loaded in Outlook.

  • The Reminders collection contains a Reminder object for each reminder.

The most prominent objects in the Outlook user interface are represented in VBA by items whose names reflect the object types. For example:

  • The MailItem object represents a mail item.

  • The ContactItem object represents a contact.

  • The TaskItem object represents a task.

  • The AppointmentItem object represents an appointment.

  • The JournalItem object represents a journal entry.

  • The NoteItem object represents a note.

You'll learn how to work with these objects later in this chapter and in the next chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.92.138