Bulk Move Phone Numbers to a Different Phone Field

Last reviewed on July 10, 2013   —  16 comments

Willy shared this with us:

"I found your very interesting page on how to bulk edit "FileAS" info for Outlook contacts. I have a Palm Pre 2 and Microsoft Exchange sync. Due to a bug, phone numbers entered in "Other Phone" field in Outlook won't sync with the smartphone. I was seeking a way to mass edit my contacts to move "other phone" to "mobile phone" (when empty). I used your script and put the following lines in the part used for "FileAs":

If .OtherTelephoneNumber <> "" Then
If .MobileTelephoneNumber = "" Then
.MobileTelephoneNumber = .OtherTelephoneNumber
.OtherTelephoneNumber = ""
.Save
End If
End If

It worked like a charm. From 160+ contacts with "OtherPhone", I ended up with less than 10 where Mobile phone was not empty and I needed to store the phone number in another category (home or business or Notes as text). Your code saved my day. Thanks"

VBA Sample

Press Alt+F11 to open the VBA editor then copy and paste into ThisOutlookSession then run. Note that it works on the contacts in the default contacts folder.

I tested this code in Outlook 2010. It should work just fine in Outlook 2003 and Outlook 2007. (May trigger the Email security prompts in Outlook 2003.)

Public Sub MovePhoneNumber()
    Dim objOL As Outlook.Application
    Dim objNS As Outlook.NameSpace
    Dim objContact As Outlook.ContactItem
    Dim objItems As Outlook.Items
    Dim objContactsFolder As Outlook.MAPIFolder
    Dim obj As Object

    On Error Resume Next

    Set objOL = CreateObject("Outlook.Application")
    Set objNS = objOL.GetNamespace("MAPI")
    Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
    Set objItems = objContactsFolder.Items

    For Each obj In objItems
        'Test for contact and not distribution list
        If obj.Class = olContact Then
            Set objContact = obj

     With objContact

          If .OtherTelephoneNumber <> "" Then
            If .MobileTelephoneNumber = "" Then
                .MobileTelephoneNumber = .OtherTelephoneNumber
                .OtherTelephoneNumber = ""
            .Save
            End If
        End If

     End With
        End If

     Err.Clear
    Next

    Set objOL = Nothing
    Set objNS = Nothing
    Set obj = Nothing
    Set objContact = Nothing
    Set objItems = Nothing
    Set objContactsFolder = Nothing
End Sub

More Information

This macro moves the number from the other phone number field to the mobile phone field if the mobile phone field is empty.

The original code is at Bulk Change Outlook Contact's Email Display Name format

To change the File as format on existing contacts, see Bulk Change File As Format for Contacts.

About Diane Poremsky

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlook forums by Slipstick.com.

16 responses to “Bulk Move Phone Numbers to a Different Phone Field”

  1. Caroline Barnard

    Thank you, this was exactly what I needed when setting up a new phone!

  2. PJS

    Hi there. Could this script be edited to only move numbers starting with '07' in the Other Phone filed to the Mobile Number field?
    Thanks in advance for any suggestions as to where this should go - as I have 2000+ contacts with a combination of numbers stored in the wrong fields!

    1. Diane Poremsky

      You'd use If left(.mobileTelephoneNumber,2) = "07" Then to detect the 07.
      if i correctly understand what you want to do... the code will look like this - it checks the mobile #, if 07 is found, moves it to other field then clears the mobile #.
      If left(.mobileTelephoneNumber,2) = "07" Then
      .OtherTelephoneNumber = .MobileTelephoneNumber
      .MobileTelephoneNumber = ""

  3. CJB

    How would you use this to append to an existing field? I want to add the 'Category' field to the beginning of the event name, so that it looks like 'Category | Event Name'

    1. Diane Poremsky

      You'd add objContact.subject = objContact.category & " | " & objContact.subject

  4. T. Clappers

    How can I alter the script so that only a certain folder will be used? I have a folder named nokia which has incorrect fields.

    Regards,

    1. Diane Poremsky

      Get the code here and replace the text between the With objContact and End With with the code from the same block on this page. The code works on the selected items, if you want to do the entire folder, Select All (Ctrl+A) before running.

  5. Bahno

    Thank you, Diane. It was really helpful! Regards Bahno

  6. Dennis

    Hi Diane,

    Is there a way to have this script of yours apply to a sub folder created underneath the default contact folder in outlook 2010 ??

    Thanks for your assistance in this matter :-)

    With kind regards,

    Dennis

    1. Diane Poremsky

      Yes, you can. Use the code in this file - the block between With objContact/End With is replaced by the same block from this page.

    2. Diane Poremsky

      BTW, that code works on the selected contacts folder, not just subfolders. If you really want to use a subfolder, you'd change the line that set the folder to this:

      Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts).Folders("Subfolder-name")

  7. Dennis

    Thanks a lot for your quick reply Diane ( Greatly respect the knowledge sharing you perform )

    With kind regards,

    Dennis

  8. thepasbox

    Thanks you, Diane!

  9. Kumar S R

    Thanks a ton Diane. That was genius. Having no idea about VB coding, I transferred my contacts! Kudos ...

  10. Michael A

    Fantastic! It worked like a charm.

  11. Sunil Avhad

    Thanks Slipstick and ThanksWilly.
    I could cut/paste your script and update my 800+ contacts in virtually one minute.

    Thanks a Ton. It saved my great headache and my hours of work.

Leave a Reply

If the Post Comment button disappears, press your Tab key.

This site uses XenWord.