Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating mailing lists in outlook web access Greener2224 Excel Discussion (Misc queries) 1 November 7th 08 03:05 PM
Validation look-up lists showing in 8 point, too small read easily David Cutlan Excel Worksheet Functions 1 January 17th 08 03:18 AM
Create Outlook Distribution lists in Excel VBA [email protected] Excel Discussion (Misc queries) 3 October 8th 07 06:51 PM
How do I move excel address lists to outlook. and vice versa. Lost in Office Excel Discussion (Misc queries) 1 April 9th 05 04:35 PM
Read Only when download from Outlook Consulting Joan Excel Discussion (Misc queries) 2 March 19th 05 03:00 PM


All times are GMT +1. The time now is 08:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"