Thread: Contacts
View Single Post
 
Old 06-28-2015, 09:54 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,142
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following macro will list the groups a named member appears in:
Code:
Sub ListDistributionGroupNamesContainingMember()
Dim olNameSpace As Outlook.NameSpace
Dim olFolder As Outlook.Folder
Dim olDistList As Outlook.DistListItem
Dim olFolderItems As Outlook.Items
Dim olListMember As String
Dim sList As String
Dim x As Integer
Dim y As Integer
Dim iCount As Integer

    olListMember = LCase(InputBox("Enter name of list member to be found", _
                                  "Find name in Distribution Lists"))
    Set olNameSpace = GetNamespace("MAPI")
    Set olFolder = olNameSpace.GetDefaultFolder(olFolderContacts)
    Set olFolderItems = olFolder.Items
    iCount = olFolderItems.Count
    sList = ""
    For x = 1 To iCount
        If TypeName(olFolderItems.Item(x)) = "DistListItem" Then
            Set olDistList = olFolderItems.Item(x)
            For y = 1 To olDistList.MemberCount
                If InStr(1, olDistList.GetMember(y).Name, olListMember) Then
                    If sList = "" Then
                        sList = sList & olDistList.GetMember(y).Name _
                                & Chr(32) & ChrW(8212) & Chr(32) & olDistList.DLName
                    Else
                        sList = sList & vbCr & olDistList.GetMember(y).Name _
                                & Chr(32) & ChrW(8212) & Chr(32) & olDistList.DLName
                    End If
                End If
            Next y
        End If
    Next x
    MsgBox sList
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote