Solved

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

Posted on 2008-10-03
4
325 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

688 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