Assign a Form to an Item

Tell Outlook to use your custom form instead of the default form to display an item.

Last modified: 2009/09/23 | Accessed: 32.746  | #75
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

Outlook decides by the value of an item's MessageClass property which form to use to display the item. As that value is stored for each item, it is not sufficient just to assign a new form to a folder. Because old items would still display with the old form.

With the following macro you can update the property for all items in the current folder. For that you need to enter the name of the new form. For instance, the name of the default form for emails is 'IPM.Note'; the name of your form then could be 'IPM.Note.MyForm'.

After you have copied the macro to the module 'ThisOutlookSession' in the VBA editor, you can call it by pressing alt+f8.

tip  How to add macros to Outlook
Public Sub ChangeMessageClassForFolderItems()
  Dim Items As Outlook.Items
  Dim obj As Object
  Dim OldClass$
  Dim NewClass$
  Dim i&

  Set Items = Application.ActiveExplorer.CurrentFolder.Items
  If Items.Count > 1 Then
    OldClass = Items(1).MessageClass
    NewClass = InputBox("Change MessageClass property of all items to: " _
      , "Change MessageClass", OldClass)
    If NewClass = "" Or LCase$(NewClass) = LCase$(OldClass) Then
      Exit Sub
    End If
    For i = 1 To Items.Count
      Set obj = Items(i)
      obj.MessageClass = NewClass
  End If
End Sub
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message