View Single Post
  #11  
Old August 22nd 06, 07:04 AM posted to microsoft.public.outlook.contacts,microsoft.public.outlook.program_vba
stef
external usenet poster
 
Posts: 83
Default displaying international format phone numbers

Eric Legault [MVP - Outlook] wrote:
Try this, but make sure to set a breakpoint on the Save line and do not
proceed with saving until you've verified that this Format function is
changing the phone number as you'd expect. If ANY phone numbers don't meet
the expected +########### format, they get all messed up.

Sub ChangeTelFormat()
Dim objC As Outlook.ContactItem
Dim strX As String

If ActiveExplorer.Selection.Count = 0 Then Exit Sub
If ActiveExplorer.CurrentFolder.DefaultItemType olContactItem Then
Exit Sub

For Each objC In ActiveExplorer.Selection
strX = Format(objC.BusinessTelephoneNumber, "+1 (@@@) @@@-@@@@")
objC.BusinessTelephoneNumber = strX
objC.Save
Next

Set objC = Nothing
End Sub


I changed the strx format as "+@ (@@@) @@@-@@@@" as the +1 is already
part of the number I have: +18008888888

I added an "End If" at the end, and checked it w/debugger and ran it but
no changes at all in folder "test". nothing bad, nothing good. just
nothing....

i checked the telephone format and it's all good there but....

by the way, these contact numbers are in the Test folder from copying
them from another folder into which i imported the numbers from a phone
with XTDN. dt know if it makes a difference as far as OL reading them
properly or not.

Here is what i ran:

Sub ChangeTelFormat()
Dim objC As Outlook.ContactItem
Dim strX As String

If ActiveExplorer.Selection.Count = 0 Then Exit Sub
If ActiveExplorer.CurrentFolder.DefaultItemType olContactItem Then
Exit Sub

For Each objC In ActiveExplorer.Selection
strX = Format(objC.BusinessTelephoneNumber, "+@ (@@@) @@@-@@@@")
objC.BusinessTelephoneNumber = strX
objC.Save
Next

Set objC = Nothing
End If

End Sub
Ads