Microsoft KB Archive/170301

From BetaArchive Wiki

Article ID: 170301

Article Last Modified on 1/20/2007


  • Microsoft Outlook 97 Standard Edition

This article was previously published under Q170301


This article describes how you can update items in a Microsoft Outlook folder so they use a custom form instead of the standard Outlook form.


There are several situations in Outlook where you might want to change the form that is used for all the items in a folder, for example:

  • You use the default Outlook form to enter 10 contacts into your Contacts folder. You then create a special custom form for contacts and enter 10 additional contacts. You want the first 10 contacts, when opened, to use the new custom form.
  • You create a custom form for contacts and enter 10 contacts using the custom form. You then import 100 contacts from a text file. The 100 imported contacts use the default form instead of the custom form.
  • You have a public folder with 1000 posted items based on the default post form. You then create a custom form that shows the items in a way that is important to your work. You want to apply the new form to the 1000 existing items.

A property of the item called message class determines what form the item uses. You cannot change the message class of an item manually. However, you can write VBScript or Automation code to change the message class for all items in a folder.

When you create and publish a custom form, the form is assigned a message class. This message class determines which form is associated with an item. The format of the name is usually IPM.<FolderType>.<FormName>, where <FolderType> is the type of folder (Contact, Task, and such.) and <FormName> is the name of the form. For example, if you create a new form named Revised and publish it to your contact folder, the message class is IPM.Contact.Revised.

The following table lists the various names used for message classes:

   Item           Default folder  Default message class
   -------------  --------------  ---------------------
   Contact        Contacts        IPM.Contact
   Task           Tasks           IPM.Task
   Appointment    Calendar        IPM.Appointment
   Note           Notes           IPM.StickyNote
   Journal Entry  Journal         IPM.Activity
   Mail           Inbox           IPM.Note

To see the message class for an existing item, add the Message Class field as one of the columns in the current view. To add the message class to your view, follow these steps :

  1. On the View menu, click Field Chooser.
  2. In the Field Chooser list, click to select All Contact Fields.
  3. Drag the Message Class field to the view column header to add the field as a column.

The message class in this view is read-only; you cannot type in a different message class to change the form manually.

Changing the message class field of existing items requires that you use Visual Basic Scripting Edition (VBScript) code in an Outlook form, or Visual Basic for Applications code from another program to automate Outlook and change the message class fields.

The following are two methods of changing message class fields:

Download the Omsgclas.exe Utility

Download Omsgclas.exe, which contains a Word 97 document with a macro utility that displays a dialog box with options for changing Outlook message classes. The macro runs automatically when you open the document.

For additional information about obtaining the Omsgclas.exe file, including a link to the file, click the article number below to view the article in the Microsoft Knowledge Base:

201089 OL2000: Word Document to Change Message Class of Outlook Items

Create a VBScript Routine

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please visit the following Microsoft Web site:

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:

Follow the steps below to create and run a VBScript routine that will change all the items in a folder to a specified form. This example assumes that you have published a new form called MyNewForm in the current folder. If you use a different title for your form, modify the form title used in the third line of code in the section "Enter the VBScript Code."

  • Create a new item to store the VBScript code
  • Enter the VBScript code
  • Run the VBScript code

Create a New Item to Store the VBScript Code

  1. Open the folder that contains the items you wish to update.
  2. On the File menu, point to New, and click the appropriate item. For example, if you want to create a new item in the Contacts folder, click Contact. You can later move the item to a different folder if you do not wish to keep this item in this folder, but the item must temporarily be in the folder for the VBScript code to function correctly.
  3. On the Tools menu, click Design Outlook Form to enter the form design mode.

Enter the VBScript Code

  1. On the Form menu, click View Code.
  2. In the Script Editor, type the following code. You do not need to enter the lines that begin with an apostrophe, since these lines are comments that are ignored when executed.

    Sub Item_Open
       ' Change the following line to your new Message Class
       NewMC = "IPM.Contact.MyNewForm"
       ' Set cf to the current folder
       Set CurFolder = Application.ActiveExplorer.CurrentFolder
       ' Loop through all of the items in the folder
       For I = 1 to CurFolder.Items.Count
          Set CurItem = CurFolder.Items.Item(I)
          ' Test to see if the Message Class needs to be changed
          If CurItem.MessageClass <> NewMC Then
             ' Change the Message Class
             CurItem.MessageClass = NewMC
             ' Save the changed item
          End If
       MsgBox "Done."
    End Sub
  3. On the Script Editor File menu, click Close.
  4. On the Tools menu, click Design Outlook Form to exit the form design mode.
  5. On the toolbar, click Save and Close, to save the item in the current folder. If this is an item without a Save and Close button, click the X in the upper-right corner of the item's window and then click Yes when asked to save changes.

Run the VBScript Code

  1. To run the VBScript code, open the item. The code will run automatically because it was entered into an Item_Open event procedure. If you receive a macro warning, click Enable Macros.
  2. Wait while the code changes the message class for all of the items in this folder. Depending on the number of items, this may take several minutes. When the code finishes, you should receive a message that says, Done.

If you wish to edit the VBScript code later, hold down the SHIFT key when you open the item. This prevents the VBScript code from executing and you can go into design mode and make changes to the VBScript code.


For additional information about creating solutions with Microsoft Outlook, click the article numbers below to view the articles in the Microsoft Knowledge Base:

166368 OL97: How to Get Help Programming with Outlook

170783 OL97: Q&A: Questions About Customizing or Programming Outlook

Additional query words: OutSol OutSol97

Keywords: kbcode kbhowto kbprogramming KB170301