OL2000: How to Use the Intellisense Feature in Outlook to Format Custom Phone Number Fields (266267)



The information in this article applies to:

  • Microsoft Outlook 2000

This article was previously published under Q266267

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.

This script written in VBScript 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: For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
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 "Phone" changed.
   If Name = "Phone" Then
       Set objPhoneFld = Item.UserProperties("Phone")
       ' 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
				

REFERENCES

For additional information about available resources and answersto commonly asked questions about Microsoft Outlook solutions, click the article number below to view the article in the Microsoft Knowledge Base:

146636 OL2000: Questions About Custom Forms and Outlook Solutions


Modification Type:MajorLast Reviewed:9/29/2003
Keywords:kbhowto KB266267