Microsoft KB Archive/294550

= OL2002: How to Use the Intellisense Feature in Outlook to Format Custom Phone Number Fields =

Article ID: 294550

Article Last Modified on 11/23/2006

-

APPLIES TO


 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q294550





SUMMARY
This article explains how to use Visual Basic Scripting Edition (VBScript) to automatically format a custom field so that it appears in the standard phone number format that is used by Outlook.



MORE INFORMATION
The standard phone number fields offer a certain degree of intellisense formatting. This means that when you type a number in the field, Outlook tries to determine the correct format for that telephone number, and then Outlook parses in the appropriate characters. For example, 4255555555 becomes (425) 555-5555.

This intellisense feature is not available with user-defined fields in Outlook. However, you can create a temporary contact item to format your own phone number fields.

The sample code in this section demonstrates how to leverage the functionality in the Outlook standard phone number fields to format your own phone number field.

The following VBScript code runs on the CustomPropertyChange event of the item. It creates a temporary contact item, populates the standard field BusinessTelephoneNumber with the new value of your custom Phone field, assigns the newly formatted value to the custom field, and then deletes the temporary contact item.

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:

https://partner.microsoft.com/global/30000104

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

http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS

Sub Item_CustomPropertyChange(ByVal Name) ' Declare constants and variables Const olContactItem = 2 Dim objPhoneFld 'As UserProperty Dim objTempContact 'As Contact Item

' Run the code if &quot;Phone&quot; changed. ' Phone is the name of the user-defined field that stores ' the phone number. If Name = &quot;Phone&quot; Then Set objPhoneFld = Item.UserProperties(&quot;Phone&quot;) ' Create a temporary contact item. Set objTempContact = Application.CreateItem(olContactItem) ' Populate a standard phone field in the temp item ' with the value of the custom phone field. ' This should resolve correctly. objTempContact.BusinessTelephoneNumber = objPhoneFld.Value ' Populate the custom phone field with the newly resolved ' phone number from the standard field. objPhoneFld.Value = objTempContact.BusinessTelephoneNumber ' Delete the temporary item. objTempContact.Delete End If End Sub

