Article ID: 192861
Article Last Modified on 2/26/2004
APPLIES TO
- Microsoft Outlook 98 Standard Edition
This article was previously published under Q192861
SUMMARY
The Microsoft Outlook 98 object library allows you to initialize a new variable as a particular type of item, such as in the following example:
Dim MyContactItem As New Outlook.ContactItem
However, this syntax should not be supported by the object model and may cause subsequent problems in the code you are creating for a solution.
MORE INFORMATION
All items should be created using the CreateItem or Items.Add methods. The following Visual Basic for Applications example illustrates how to properly early-bind a new object variable and then set it to a new item of a specific type. Be sure to reference the Outlook 98 object library before running this code.
Sub CreateContact() Dim ol As New Outlook.Application Dim MyContactItem As Outlook.ContactItem Set MyContactItem = ol.CreateItem(olContactItem) MyContactItem.Display End Sub
NOTE: Although the syntax described in the Summary section of this article may work in your solution, future versions of Outlook will not allow this syntax. A compile error will be generated before the code is run.
REFERENCES
For more information about creating solutions with Microsoft Outlook 98, please see the following articles in the Microsoft Knowledge Base:
Additional query words: OutSol OutSol98
Keywords: kbinfo kbprogramming KB192861