Solved

Script to change contacts phone numbers

Posted on 2006-11-22
5
296 Views
Last Modified: 2010-04-08
Hi,

Just changed my phone & my new phone wont show the callers name as the phone numbers are in a different format, ie there is no international dialing code.  I syncronise with my outlook contacts (no prises for guessing what kinda phone!)

So  I am looking for a script (preferabally a cscript as we will be rolling these phones out to a number of other people shortly) that I can run that will update the phone numbers in my outlook contacts, and prefix them with the international dialing code.

If I have the code that would open, alter & save the update, I could customise to suit.  Eg some numbers will have area codes, some will be local only etc so it will take a bit of tuning to get right.

regards

J
0
Comment
Question by:thirtysomething
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17998151
Hi J,

> Eg some numbers will have area codes, some will be local only etc so it will take
> a bit of tuning to get right.

Please detail all the rules you want applied to the phone numbers.

Also, be advised that running this kind of script may very well trigger an Outlook security warning, so make sure
the other people running this script will know how to respond.

Regards,

Patrick
0
 

Author Comment

by:thirtysomething
ID: 18000276
Patrick,

Thanks for the feedback.

The rules will have to develop.  I have enough programming ability (just about) to do the detailed numbers changing if I had a base script to work off.  Looking at my own 900ish contacts they are in a mess so it will take a few goes.

For the other users, we will be working with them on a one to one basis running contact duplicate removers, moving contacts from SIMs etc so will be running it with them.  To have to go through phone numbers individually would do everybodys nut in.  We would probabally run it on behalf of the users

A sample would be if phone number starts with 087 change it to +353 (87)....

J

Cá bhuil tú i do chónaí?
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 499 total points
ID: 18000443
J,

You could start with this VBScript:




Sub ModifyPhone()

    Dim olApp, olNS, olMF, olContact

    Set olApp = CreateObject("Outlook.Application")
    Set olNS = olApp.GetNameSpace("MAPI")
    Set olMF = olNS.GetDefaultFolder(10) 'Contacts

    For Each olContact In olMF.Items
        If olContact.Class = 40 Then
            'put in your code here for phone number stuff
            'many properties available
            'AssistantTelephoneNumber
            'BusinessTelephoneNumber
            'Business2TelephoneNumber
            'CallbackTelephoneNumber
            'CarTelephoneNumber
            'CompanyMainTelephoneNumber
            'HomeTelephoneNumber
            'MobileTelephoneNumber
            'OtherTelephoneNumber
            'PrimaryTelephoneNumber
            'RadioTelephoneNumber
            'TTYTDDTelephoneNumber
        End If
    Next

    Set olContact = Nothing
    Set olMF = Nothing
    Set olNS = Nothing
    Set olApp = Nothing

End Sub

Regards,

Patrick
0
 

Author Comment

by:thirtysomething
ID: 18002425
Patrick,

Perfect!!!!

I wrote a subroutine called fixnumber to do the tidying for a given number & added the following to your code.  These are the main fields of interest to me, the only ones I had to add were the fax numbers

        olContact.HomeTelephoneNumber  = fixnumber(olContact.HomeTelephoneNumber )
        olContact.AssistantTelephoneNumber  = fixnumber(olContact.AssistantTelephoneNumber )
        olContact.BusinessTelephoneNumber  = fixnumber(olContact.BusinessTelephoneNumber )
        olContact.Business2TelephoneNumber  = fixnumber(olContact.Business2TelephoneNumber )
        olContact.BusinessFaxNumber  = fixnumber(olContact.BusinessFaxNumber )
        olContact.CompanyMainTelephoneNumber  = fixnumber(olContact.CompanyMainTelephoneNumber )
        olContact.HomeTelephoneNumber  = fixnumber(olContact.HomeTelephoneNumber )
        olContact.HomeFaxNumber  = fixnumber(olContact.HomeFaxNumber )
        olContact.MobileTelephoneNumber  = fixnumber(olContact.MobileTelephoneNumber )
        olContact.OtherTelephoneNumber  = fixnumber(olContact.OtherTelephoneNumber )
        olContact.PrimaryTelephoneNumber  = fixnumber(olContact.PrimaryTelephoneNumber )
' save the changes to Outlook
        olContact.save


Full marks for response time & working code sample
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 18003299
Glad to help :)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
If you don't know how to downgrade, my instructions below should be helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now