How to Delete Country Code from Phone Numbers in Contacts

  • Thread starter Thread starter carolina girl
  • Start date Start date
C

carolina girl

I bought a new Microsoft 7 based computer and restored my .pst files to
Office 2007 on it. Now all of my phone numbers are formatted with a +1 in
front of the 10 digit number. I have researched this issue for 3 days and
have not found a solution that works to delete this +1 which I believe is the
country codde.

Does anyone have a fix for this?
 
I am wondering the same thing.

The answer you speak of is hardly useful, he asked why you would need to
change that. FYI an answer is a solution to the problem, not another
question.

Does anyone have a real answer?

Thx
Force
 
You may go to the VBA in Outlook, create a module and run the macro. Am not a programmer and created this code in 2 hours straight as I could not find any thing similar on the web. Make suitable changes to the values in the code, comments have been provided for that purpose.


Sub CorrectContactInfo()
'I Have used " _" to break long statements into multiple lines (read without the quotes)
'Check for number of contacts
Dim ContactsFolder As Folder
Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)
MsgBox ("Contacts Found: " & ContactsFolder.Items.Count)

'Run to identify and make changes
'Declare Variables
Dim Contact As ContactItem
Dim Pos As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim StrLength As Integer

'Initialize default values
i , j, k = 0

'Iterate for each contact in the address book
For Each Contact In ContactsFolder.Items

i = i + 1 'for validating results
Pos = 0 'Inside the loop value reser for each iteration

Pos = InStr(1, _
Contact.BusinessTelephoneNumber, _
"0", _
vbBinaryCompare) 'replace "0" to search for the required value
'Also, BusinessTelephoneNumber is one of the firelds...
'Change accordingly

StrLength = 0 'Initializing the variable
StrLength = Len(Contact.BusinessTelephoneNumber) 'get string length
If Pos = 1 Then 'If the substring is found at the beginning

j = j + 1 'checks for how many were selected for modification
'Press Ctrl+G (required only once ) to be able to view Debug info window
Debug.Print "To be changed:" & Contact.BusinessTelephoneNumber
Contact.BusinessTelephoneNumber = _
Replace(Contact.BusinessTelephoneNumber, _
"0", _
"+91", _
1, _
1, _
vbBinaryCompare) 'it does only one repalce 'cuz of the choosen parameters.
'Change "0" to what ever substring is to be replaced
'Change "+91" to what ever subrtring is to required
Contact.Save 'Save changes, can be commented out for dry run

'Press Ctrl+G to be able to view Debug info window
Debug.Print "Changed To:" & Contact.BusinessTelephoneNumber
Else
'Checks how many were not processed
k = k + 1
'Press Ctrl+G to be able to view Debug info window
Debug.Print "Untouched:" & Contact.BusinessTelephoneNumber
End If
Next
Debug.Print "Number of Contacts parsed =" & i
Debug.Print "Number of contacts for modification =" & j
Debug.Print "Number of untouched contacts =" & k
End Sub
 
Back
Top