?
Solved

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

Posted on 2011-04-19
4
Medium Priority
?
851 Views
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??
0
Comment
Question by:karaflanagan
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 35497908
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
            Else
                olkCon.FileAs = olkCon.LastName & ", " & olkCon.FirstName
            End If
            olkCon.Save
        End If
    Next
    Set olkCon = Nothing
End Sub

Open in new window

0
 

Author Comment

by:karaflanagan
ID: 35505077
BlueDevilFan,

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

Expert Comment

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

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
MS Outlook undoubtedly is the most widely used email client.Its user-friendliness, cost effectiveness, and availability with Microsoft Office Suite make it the most popular email application.  Its compatibility with Microsoft applications like Exch…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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