Solved

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

Posted on 2008-10-03
4
318 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Use email signature images to promote corporate certifications and industry awards.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

705 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