OL97: How to Create a New Item Based on a Custom Form

Last reviewed: February 27, 1998
Article ID: Q165514
The information in this article applies to:
  • Microsoft Outlook 97

SUMMARY

This article describes how you can use Outlook 97 Visual Basic Scripting Edition to create a new item based on a custom form.

MORE INFORMATION

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 engineers 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/default.asp

When a form is published in Outlook 97, a message class name is used to identify the form. In VBScript, you can use this class name with the Add method of Outlook's Items collection to create a new item based on the published custom form. To obtain the message class of a custom form, open the custom form and click "Publish Form As" on the File menu. You will see the message class name in the Publish Form As dialog box, for example:

   IPM.Contact.CustomContact

The following steps will enable you to use the message class name and VBScript to create another item or copy of the current form, by adding a command button and the attached VBScript to your custom form.

To create the VBScript and command button follow these steps:

  1. Open a custom form.

  2. On the Tools menu, click Design Outlook Form.

  3. On the Form menu in Design View, click Control Toolbox.

  4. Drag the Command Button to your form from the Toolbox.

  5. On the Form menu, click View Code to open the Script Editor.

  6. In the Script Editor, type the following code and substitute the message class name for your custom form:

       Sub CommandButton1_Click()
          Set MyFolder = Item.Application.ActiveExplorer.CurrentFolder
          Set MyItem = MyFolder.Items.Add("<IPM.FormType.FormName>")
          MyItem.Display
       End Sub
    
    

  7. On the File menu in the Script Editor, click Close to return to your form.

  8. On the Tools menu, click Design Outlook Form to switch out of the Design View.

    NOTE: If the Script Editor detects an error in your code, it will display a message at this point.

  9. On the File menu, click Publish Form As and then click Publish.

  10. On the File menu, click Close. Do not save changes when prompted.

REFERENCES

For more information about creating solutions with Microsoft Outlook 97, please see the following articles in the Microsoft Knowledge Base:

   Article-ID: Q166368
   Title     : OL97: How to Get Help Programming with Outlook

   Article-ID: Q170783
   Title     : OL97: Q&A: Questions about Customizing or
               Programming Outlook


Additional query words: OutSol OutSol97

Version : 97
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 27, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.