Script to change Display As in Outlook Contacts for Outlook 2010 with Exchange Server 2010

Some of my clients would like to have the auto-complete for addresses in the "To" field go based on last name.  I figured out that by changing the "Display As" field in the contact form I could get this to work, however, there are hundreds of contacts being carried over from a previous email client with this upgrade.  is there a fast way to change this on all the contacts without editing each individual contact?  A code of some kind or an option I could change either in the Outlook application or the  Server itself??
Who is Participating?
David LeeCommented:
Hi, karaflanagan.

If I've correctly understood what you want to accomplish, then this code should get the job done.  This macro will change the display name for all contacts to either "FIRST LAST" or "LAST, FIRST" format.  Changing the format of the existing contacts is only half the battle. You'll also need to change the default for new contacts.  To do that click Tools, Account Settings, Address Books tab. Select Outlook Address Book and click Change to view or change the default for new contacts.  Keep in mind that both running the code and changing the default will have to be done at every computer.

Follow these instructions to use the code.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor
10. Select the contacts folder to run against.
11. Run the macro.
Sub ChangeContactDisplayNames()
    'On the next line set DISPLAYFORMAT to 0 for "First Last" format or 1 for "Last, First" format'
    Dim olkCon As Object
    For Each olkCon In Application.ActiveExplorer.CurrentFolder.Items
        If olkCon.Class = olContact Then
            If DISPLAYFORMAT = 0 Then
                olkCon.FileAs = olkCon.FirstName & " " & olkCon.LastName
                olkCon.FileAs = olkCon.LastName & ", " & olkCon.FirstName
            End If
        End If
    Set olkCon = Nothing
End Sub

Open in new window

karaflanaganAuthor Commented:

Thank you so much.  This looks like it will work.  I will let you know if I have other questions regarding this.  I really appreciate the time and effort you spent on this.  Thanks!!
David LeeCommented:
You're welcome!  Glad I could help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.