Last reviewed on May 7, 2015   —  18 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

More Articles at Slipstick.com:

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.

Comments

  1. PJS says

    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!

    • Diane Poremsky says

      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 = ""

  2. CJB says

    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'

  3. T. Clappers says

    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,

    • Diane Poremsky says

      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.

  4. Dennis says

    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

    • Diane Poremsky says

      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")

  5. Dennis says

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

    With kind regards,

    Dennis

  6. Sunil Avhad says

    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.

  7. Khalil says

    Dear Diane , that's so technical for a user like me ... Can you give me a simple way to change all the fields in my contacts from the "other" field to for example "home" field ... I use Microsoft exchange of my company & it's not reading the "other" field on my smart phones

Leave a Reply

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

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