Create a list of Contact Group members and their phone numbers

Last reviewed on December 4, 2012

A user wanted to know how to customize a Contact Group (distribution list) to display the list member's phone numbers. His goal: print a list of contact group members and their phone numbers to distribute to co-workers.

One method is to use the macro at Add a Category to Contacts in a Contact Group (DL) to add a category to each member's contact then filter on that category. Use a list view and remove the fields you don't need from the view. Then you can copy it (paste into and email message, Notepad, or Excel, or paste special into Word) or print it. One benefit of this method is that it works with very large lists and a large number of fields.

Create a list of contact group members and their phone numbersAnother option is to tweak the aforementioned macro to create a list of contacts and their phone numbers and insert it into a new message form. It's possible to write it to Notepad, Word, or Excel but you can print, copy, or email the list from the message form.

This method is best suited for smaller contact groups and/or fewer fields, as you are committing the contact data to memory and writing it to the message form at the end.

Create a list of Contact Group Members macro

To use, open the VBA Editor using Alt+F11, right-click on Project1 and choose Insert > Module. Paste the code into the module.

Get the GetCurrentItem function from Outlook VBA: work with open item or selected item and paste it at the end of the module.

Don't forget to check your macro security settings. For testing, you'll need security set to low. When you're satisfied with it, you can sign it with a selfcert and raise the macro security level. See Using the VBA editor for specifics.

Open or select the Contact Group and run the macro. The member's full name and their phone number will be inserted into the body of a new message. The Contact group name is inserted into the subject field.

' Based on a macro by Valk Beekman. 
Sub listDistoMembers()
Dim N_NS As NameSpace
Dim o_fold As Items
Dim o_list As Object
Dim o_dfold As Items
Dim o_cont  As Object
Dim b_Found As Boolean

' fill in you category here.
    t_cat = "dist-1"

Set N_NS = Application.GetNamespace("MAPI")

'current contact folder
Set o_fold = Application.ActiveExplorer.CurrentFolder.Items.Restrict("[Email1Address]>''")

' Current object and should be the distributionlist
Set o_list = GetCurrentItem()

' uncomment to add the group name above the phone list
'strContacts = "Contact Group: " & o_list.Subject

'main contact folder
Set o_dfold = N_NS.GetDefaultFolder(olFolderContacts).Items.Restrict("[Email1Address]>''")

For i = 1 To o_list.MemberCount
     t_test = "[Email1Address] = '" & o_list.GetMember(i).Address & "'"
     Set o_cont = o_fold.Find(t_test)
     b_Found = Not (o_cont Is Nothing)
     If Not b_Found Then 'look in main contacts
        Set o_cont = o_dfold.Find(t_test)
        b_Found = Not (o_cont Is Nothing)
     End If
     If b_Found Then
         strContacts = strContacts & vbCrLf & o_cont.FullName & " " & o_cont.BusinessTelephoneNumber
        End If
     b_Found = False
Next

' Create the message form 
Set gpPhone = Application.CreateItem(olMailItem)
  gpPhone.Subject = "Contact Group: " & o_list.Subject
  gpPhone.Body = strContacts
  gpPhone.Display
  

End Sub

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999 and involved in IT support since 1985, Diane is the author of several books and video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.