Z
Zarqy
I'm new to Outlook vb porgramming, and have a simple question
In the code below, I am attempting to list the distribution lists in my
personal contacts folder.
The first example does the initial loop, but will not continue. Why? I
would prefer to not have to iterate over every single contact if
possible in order to speed things up.
(My eventual goal is to loop thru my contacts, and match them up with
what dl's they are in. Do I need to do the same loop inside itself to
do this? Probably best for a seperate post...)
'--- Start Example ---
Dim obj As Object
Dim oDistList As Outlook.DistListItem
Dim oContact As Outlook.ContactItem
Dim oItems As Outlook.Items
Set oItems =
Application.GetNamespace("mapi").GetDefaultFolder(olFolderContacts).Items
' Obtain List of DL's
''--- Would prefer this method as it seems it would be a faster way
For Each oDistList In oItems
Debug.Print oDistList.DLName, oDistList.MemberCount
'--- Runtime Error '13' at this line (Next)
Next
'---This loop works fine
For Each obj In oItems
If TypeOf obj Is Outlook.DistListItem Then
Set oDistList = obj
Debug.Print oDistList.DLName, oDistList.MemberCount
End If
Next
In the code below, I am attempting to list the distribution lists in my
personal contacts folder.
The first example does the initial loop, but will not continue. Why? I
would prefer to not have to iterate over every single contact if
possible in order to speed things up.
(My eventual goal is to loop thru my contacts, and match them up with
what dl's they are in. Do I need to do the same loop inside itself to
do this? Probably best for a seperate post...)
'--- Start Example ---
Dim obj As Object
Dim oDistList As Outlook.DistListItem
Dim oContact As Outlook.ContactItem
Dim oItems As Outlook.Items
Set oItems =
Application.GetNamespace("mapi").GetDefaultFolder(olFolderContacts).Items
' Obtain List of DL's
''--- Would prefer this method as it seems it would be a faster way
For Each oDistList In oItems
Debug.Print oDistList.DLName, oDistList.MemberCount
'--- Runtime Error '13' at this line (Next)
Next
'---This loop works fine
For Each obj In oItems
If TypeOf obj Is Outlook.DistListItem Then
Set oDistList = obj
Debug.Print oDistList.DLName, oDistList.MemberCount
End If
Next