-
What's wrong with this ?
I have a small piece of code in which I just try to retrieve the names of all Outlook contacts and put them in a listbox.
This gives me a runtime error '13': Type mismatch at the last line of code (Next objEntry):
Dim objOutlook As New Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objContacts As MAPIFolder
Dim objEntry As ContactItem
'Get the MAPI reference
Set objNameSpace = objOutlook.GetNamespace("MAPI")
'Pick up the Contacts
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
'Loop through the folders under the Inbox
For Each objEntry In objContacts.Items
lstfolders.AddItem objEntry.LastName
Next objEntry
Any idea's ???
-
I just tested it and it works fine. Are you refrencing the outlook 9.0 library?
-
Yes I have.
Is it possible that it has something to do with the large number of
contacts that i have ?
-
Yes I have.
Is it possible that it has something to do with the large number of
contacts that i have ?
-
I only had ten contacts. Send the code to someone else that has as many contacts as you and see if it crashes.
-
Change "Next objEntry" to "Next" ;-)