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

Posted on 2011-04-19
Last Modified: 2012-05-11
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??
Question by:karaflanagan
    LVL 76

    Accepted Solution

    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'
        Const DISPLAYFORMAT = 0
        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


    Author Comment


    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!!
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome!  Glad I could help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Set OWA language and time zone in Exchange for individuals, all users or per database.
    In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    761 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

    12 Experts available now in Live!

    Get 1:1 Help Now