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 IfIt 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
How to use the macro on this page
First: You need to have macro security set to the lowest setting, Enable all macros during testing. The macros will not work with the top two options that disable all macros or unsigned macros. You could choose the option Notification for all macros, then accept it each time you restart Outlook, however, because it's somewhat hard to sneak macros into Outlook (unlike in Word and Excel), allowing all macros is safe, especially during the testing phase. You can sign the macro when it is finished and change the macro security to notify.
To check your macro security in Outlook 2010 and newer, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, look at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Macros that run when Outlook starts or automatically need to be in ThisOutlookSession, all other macros should be put in a module, but most will also work if placed in ThisOutlookSession. (It's generally recommended to keep only the automatic macros in ThisOutlookSession and use modules for all other macros.) The instructions are below.
The macros on this page should be placed in a module.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor
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.
More Information
More Bulk Change Contact articles at Slipstick.com:
Hi Diane,
I'm not a very technical user, but would really be grateful if you could please help me move all numbers from the Other field into the Radio field, since the former does not sync with my smartphone. Would I be correct in assuming that .MobileTelephoneNumber in the above script would need to be replaced with .RadioTelephoneNumber for this? And if so, how might the revised script look?
Regards,
AK
yes, provided that is the correct field name (i'm on the road and didn't double check it)
If .OtherTelephoneNumber <> "" Then
If .RadioTelephoneNumber = "" Then
.radioTelephoneNumber = .OtherTelephoneNumber
'this line clears the other field - you could leave it in and have the number duplicated
'.OtherTelephoneNumber = ""
.Save
End If
End If
Thank you for that quick response. Last question - how would I go about confirming that .radioTelephoneNumber is actually the correct field name? And if it's not, how would I find the correct one? As I mentioned in the original post, I'm not very tech savvy in this regard, so grateful for the help.
three ways:
type in lower case. if the field is valid in outlook, the case changes.
after typing the object name and dot, a list of valid fields will come up. as you type letters, it will filter the list.
search the object model help. its on the view menu and in msdn (use google to find it - something like 'outlook vba contact fields'
Absolutely brilliant, worked like a charm - thank you so much!! :-)
Slipstick is my first point of reference when I need to do something like this - some months ago, needed to bulk change the Save As field for email, and you saved my life then too. Awesome, and thank you for the work you do for the MS community.
Cheers!
I want to use the script above to move information between the following two fields but do not seem to have the correct syntax for the field names as nothing moves (though I can get phone numbers in Other to move to Mobile when I try running it as shown above): User Field 2 (.UserField2) to Personal Home Page (.PersonalHomePage). I believe I have not used the correct field labels in the macro but am stumped as to what I should be using. Note: I want to do the same with User Field 3 moving to IM Address so let me know please what the correct syntax is for the IM Address field too. Thanks!
Thanks it worked on outlook 2013
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
You'll either need to use a macro or edit each contact yourself.
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.
Fantastic! It worked like a charm.
Thanks a ton Diane. That was genius. Having no idea about VB coding, I transferred my contacts! Kudos ...
Thanks you, Diane!