Solved

How do you reset the "Display As" field for all existing Outlook Contacts?

Posted on 2008-10-03
4
321 Views
Last Modified: 2012-05-05
I am using the Outlook client on the front end with a Lotus Domino server on the backend. My Lotus Notes address book syncs to an Outllook Contact Address Book but the "Display As" field in the Outllok contacts only shows the users email address.  Is there a simple way to reset all existing contacts in my Outlook Address Book to display like this  

John Doe <jdoe@domain.com>

I know I can reset each individual one by deleting the "Display As" field and then clicking into another field and it will reset the Display As field.  However I have 600 contacts in my address book and don't want to do this manually.

Any help would be appreciated.
0
Comment
Question by:rdgit
  • 2
  • 2
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22635875
Hello rdgit,

This should work, written to run from Outlook.

Regards,

Patrick
Sub ResetDisplayAs()
    
    Dim ns As NameSpace
    Dim fld As MAPIFolder
    Dim it As Variant
    Dim c As ContactItem
    
    Set ns = Application.GetNamespace("MAPI")
    Set fld = ns.GetDefaultFolder(olFolderContacts)
    
    For Each it In fld.Items
        If it.Class = olContactItem Then
            Set c = it
            c.FileAs = c.FullName & " <" & c.Email1Address & ">"
            c.Save
        End If
    Next
    
End Sub

Open in new window

0
 

Author Comment

by:rdgit
ID: 22637167
Thanks for the quick reply.

I have loaded the macro in outlook but when I run it, nothing happens.
I am new to outlook so I may be doing something wrong.
I go into the Contacts view then click Tools..Macro..Macro.
I then select ResetDisaplayAs and click Run.
the dialog box goes away but nothing changes.

I have tried selecting multiple contact and  then running it but it doesn't do anything either.

Am I doing something wrong?
Thanks!

0
 

Author Comment

by:rdgit
ID: 22652753
Hello,
I was able to verify that Im running it, its searching through each of my contacts but when it gets to the IF statement, it isnt seeing something correctly... ( If it.Class = olContactItem Then)& olContatitem is always at a value of 2?  I also noticed that the & c & or the contact item& never has a value, so even if I took the if statement out it wouldnt be able to set it to anything.  Any help you could provide would be great!

0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 50 total points
ID: 22743284
rdgit,

Sorry for the delay.  I was using the wrong value for the class type.  I tested the snippet below, and it
appears to work.

Regards,

Patrick
Sub ResetDisplayAs()
    
    Dim ns As NameSpace
    Dim fld As MAPIFolder
    Dim it As Variant
    Dim c As ContactItem
    
    Set ns = Application.GetNamespace("MAPI")
    Set fld = ns.GetDefaultFolder(olFolderContacts)
    
    For Each it In fld.Items
        If it.Class = olContact Then
            Set c = it
            c.FileAs = c.FullName & " <" & c.Email1Address & ">"
            c.Save
            Debug.Print c.FileAs   'for debugging
            Exit For               'for debugging
        End If
    Next
    
    Set fld = Nothing
    Set ns = Nothing
    
End Sub

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

829 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