Solved

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

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Finding a closest match in Excel 7 47
Outlook VBA worked in 2013 but not in 2016 6 40
Outlook sent emails not present in sent items 2 25
open ost file into new machine? 7 53
What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
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: …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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