Vertex42 The Excel Nexus

Professional Excel Templates

Get Instant Access

Plain Text Supports Inspector Does not support Inspector Supports Inspector Supports Inspector

Plain Text Supports Inspector Does not support Inspector Supports Inspector Supports Inspector

Outlook 2002 fixes the problematic Inspector behavior found in Outlook 2000. Word is the default e-mail editor in Outlook 2002. The Newlnspector event will always fire in Outlook 2002 and is not dependent upon the default e-mail editor or the mail format.

There are other circumstances where you cannot instantiate an Inspector object when a user or program code creates or modifies an item in a folder. An Outlook 2002 Office Document item does not support an Inspector object. A Documentltem object is any document-other than an Outlook item-that exists as an item in an Outlook folder. In common usage, an IPM.Document item will be an Office Document, but it may also be any type of document, an executable file, or an HTML document. Remember that Exchange folders can contain almost any type of Document item. Moreover, Office Document items can be posted or sent directly to a folder either by a user action or by program code. In this instance, the Documentltem objects do not support an Inspector object. The following table indicates when a Documentltem object supports an Inspector object.

Document Item

Message Class

Supports Inspector for Outlook Document Item

Supports Inspector for Native Document Item

Web Page

IPM. Document.htmlfile

Not applicable


Word Document

IPM.Document.Word. Document.8

Yes, if created by Outlook 2000 or earlier


Excel Worksheet

IPM. Document. Excel.Sheet.8

Yes, if created by Outlook 2000 or earlier


PowerPoint Presentation

IPM. Document. PowerPoint. Show.8

Yes, if created by Outlook 2000 or earlier


Visio Drawing

IPM. Document.*.VSD



Earlier versions of Outlook allowed you to create custom forms based on the Outlook Office Document item. These forms wrapped a native Office document (such as a Word document, an Excel worksheet, or a PowerPoint presentation) in an Outlook Inspector. This functionality is not available in Outlook 2002. When you select the Office Document command from the New submenu of the File menu in Outlook 2002, you will see the New Office Document dialog box. When you select an Office Document type in this dialog box, you launch the hosting application and can save the document to the file system, Web storage, or an Exchange folder. You cannot create and design custom Outlook Office Document items in Outlook 2002. Outlook Office Document items still open and function correctly in Outlook 2002, but you must use an earlier version of Outlook if you want to create and design these forms.

If you post an Office document such as an Excel workbook or a PowerPoint presentation directly to a folder, an Inspector object will not be created. The Newlnspector event will not fire when you add a native Office document to an Exchange folder. If you post or send an Office Document item created in a version of Outlook earlier than Outlook 2002, the Newlnspector event will fire. Posting any other document, whether it is an HTML document, a .zip file, a .pdf file, or any other type of document that can be posted to a public folder, will not cause the Newlnspector event to fire.

If an application external to Outlook creates an Outlook Inspector object, the Newlnspector event will not fire if an Inspectors collection object has been instantiated by Outlook VBA or an Outlook COM Add-in. An external application is an application that uses Simple MAPI to create an Outlook mail message. This limitation does not apply to applications that use Outlook as an ActiveX Automation Server to create Outlook items. For example, you can send a file as an attachment to an Outlook message by selecting the Mail Recipient MAPI command on the Send To menu of the file's shortcut menu. Right-click the file in Wndows Explorer to display the file's shortcut menu. When you select this command, an Inspector window opens and the file is added as an attachment to an Outlook message. However, a Newlnspector event will not fire for this message. Similarly, if you use the Send Page By E-Mail or Link By E-Mail commands in Internet Explorer, a Newlnspector event will not fire. The following table illustrates when a Newlnspector event fires, depending on the calling application. You should realize that the exceptions regarding mail editor settings and message format discussed earlier will also determine whether the Newlnspector event fires.

Calling Application

Windows Explorer

Internet Explorer



Word, Excel, Visual Basic, Visual C++, or any COM-compliant ActiveX automation controller application


Send To extensions such as Mail Recipient MAPI command

File Send Page By E-Mail or Link By E-Mail

File New Mail Message

Create New Item (either through user action or program code)

Outlook automation through program code

Newlnspector Event for Inspectors Collection object

Yes, depending on default e-mail editor and message type


The Newlnspector event occurs when a new Inspector object is created either through a user action or program code. The Newlnspector event fires before the Inspector window is displayed. If you create an item through code and do not display the item, then the Newlnspector event does not occur.

As discussed earlier, the Newlnspector event is the gateway to item-level events. The following code example shows how to create item-level objects depending on the class of the item returned by the Currentltem property of the Inspector object. Once you have instantiated these form-level objects in your VBA code, you can raise events on the form-level objects in VBA as long as you have declared the form-level objects using the WithEvents keyword. All of the traditional form-level events, such as ltem_0pen, ltem_Read, ltem_Write, and ltem_Send, are available for the Item object declared using WithEvents.

The importance of this approach is that these events are now available to you in VBA or in your COM Add-in, rather than in VBScript code written for a custom form.

'Place these declarations in the general section ThisOutlookSession

Public WithEvents objlnsp As Outlook.Inspector

Public WithEvents collnsp As Outlook.Inspectors

Public WithEvents objMailltem As Outlook.Mailltem

Public WithEvents objPostltem As Outlook.Postltem

Public WithEvents objContactltem As Outlook.Contactltem

Public WithEvents objDistListltem As Outlook.DistListltem

Public WithEvents objApptltem As Outlook.Appointmentltem

Public WithEvents objTaskltem As Outlook.Taskltem

Public WithEvents objTaskRequestltem As Outlook.TaskRequestltem

Public WithEvents objTaskRequestAcceptltem As Outlook.TaskRequestAcceptltem

Public WithEvents objTaskRequestDeclineltem As Outlook.TaskRequestAcceptltem

Public WithEvents objTaskRequestUpdateltem As Outlook.TaskRequestUpdateltem

Public WithEvents objJournalltem As Outlook.Journalltem

Public WithEvents objDocumentltem As Outlook.Documentltem

Public WithEvents objReportltem As Outlook.Reportltem

Public WithEvents objRemoteltem As Outlook.Remoteltem

Private Sub collnsp_Newlnspector(ByVal Inspector As Inspector) Dim objltem As Object Set objlnsp = Inspector On Error Resume Next Set objltem = objlnsp.Currentltem Select Case objltem.Class Case olMail

Set objMailltem = objltem Case olPost

Set objPostltem = objltem Case olAppointment

Set objApptltem = objltem Case olContact

Set objContactltem = objltem Case olDistributionList

Set objDistListltem = objltem Case olTask

Set objTaskltem = objltem Case olTaskRequest

Set objTaskRequestltem = objltem Case olTaskRequestAccept

Set objTaskRequestAcceptltem = objltem Case olTaskRequestDecline

Set objTaskRequestDeclineltem = objltem Case olTaskRequestUpdate

Set objTaskRequestUpdateltem = objltem Case olJournal

Set objJournalltem = objltem Case olReport

Set objReportltem = objltem Case olRemote

Set objRemoteltem = objltem Case olDocument

Set objDocumentltem = objltem End Select End Sub

The item's class is a better guide to the type of item than the item's message class. For example, all Contact items have a class value of olContact. If you look up the olContact value in the OlObjectClass Enum, olContact has a decimal value of 40. Any contact items, whether they are default contact items with a message class of IPM.Contact or custom contact items with a message class of IPM.Contact.MyCustomContactForm, have an item class value equal to olContact.

Was this article helpful?

0 0

Post a comment