Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Read Outlook DL Lists
Hi All,
Im using the following macro to try and list the members of a contact list from Outlook 2000-(cant remember where i found it): Sub ListMembers() Dim olApp As New Outlook.Application Dim olNS As Outlook.NameSpace Dim ctFolder As Outlook.MAPIFolder Dim myDistList As Outlook.DistListItem Dim ctFolderItems As Outlook.Items Dim myRcpnt As Outlook.Recipient Dim iterateCtItems As Integer Dim iterateMembers As Integer Dim countCtItems As Integer Dim countMembers As Integer Dim R As Integer Dim criteria As String Dim itm As Object Set olNS = olApp.GetNamespace("MAPI") Set ctFolder = olNS.GetDefaultFolder(olFolderContacts) Set ctFolderItems = ctFolder.Items countCtItems = ctFolderItems.Count R = 1 For iterateCtItems = 1 To countCtItems If TypeName(ctFolderItems.Item(iterateCtItems)) = "DistListItem" Then Set myDistList = ctFolderItems.Item(iterateCtItems) If myDistList.DLName = "DL Monthly Finance Reports" Then countMembers = myDistList.MemberCount For iterateMembers = 1 To countMembers Set myRcpnt = olApp.Session.CreateRecipient(myDistList.GetMember (iterateMembers).Address) myRcpnt.Resolve If myRcpnt.Resolved = True Then criteria = "[Email1Address] = " & myRcpnt.Address Set itm = ctFolderItems.Find(criteria) Sheets("Sheet1").Cells(R, 1).Value = itm.FullName R = R + 1 End If Next iterateMembers End If End If Next iterateCtItems Set olNS = Nothing Set olApp = Nothing End Sub When i run it, i get the following error: Run-time error'-1871577079 (90720009)': Condition is not valid. Looking at the debug info, it has found the distribution list and is reading the first contact, but is failing bring across the name of the contact. It's falling over on the "Set itm = ctFolderItems.Find(criteria)" line. Can someone please help. Thanks. Tony. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Creating mailing lists in outlook web access | Excel Discussion (Misc queries) | |||
Validation look-up lists showing in 8 point, too small read easily | Excel Worksheet Functions | |||
Create Outlook Distribution lists in Excel VBA | Excel Discussion (Misc queries) | |||
How do I move excel address lists to outlook. and vice versa. | Excel Discussion (Misc queries) | |||
Read Only when download from Outlook | Excel Discussion (Misc queries) |