A
Andibevan
Hi,
I am trying to loop through all the contacts in the standard contacts
folder.
When I use "Dim objContact As ContactItem" it gets 15 items through the 600
contact items and gets a 'type mismatch' error on the 'Next Statement'
When I change it to 'Dim objContact' It prints out all items as expected.
If I print the typename for each of the 600 objContact items it says
ContactItem for each item.
Any ideas?
Tia
Andy
Sub SearchAndReplaceContacts()
On Error Resume Next
'Const olFolderContacts = 10
'Set objOutlook = CreateObject("Outlook.Application")
Dim objNamespace As NameSpace
Set objNamespace = Application.GetNamespace("MAPI")
Dim colContacts As Items
Set colContacts = objNamespace.GetDefaultFolder(10).Items
'Dim objContact As ContactItem
Dim objContact
Dim i
For Each objContact In colContacts
Debug.Print i & " - " & objContact.FullName & " - " &
objContact.Email1Address _
& " - " & objContact.Email2Address _
& " - " & objContact.Email3Address
'Debug.Print i & TypeName(objContact)
i = i + 1
Next objContact
Debug.Print colContacts.Count & TypeName(objContact)
End Sub
I am trying to loop through all the contacts in the standard contacts
folder.
When I use "Dim objContact As ContactItem" it gets 15 items through the 600
contact items and gets a 'type mismatch' error on the 'Next Statement'
When I change it to 'Dim objContact' It prints out all items as expected.
If I print the typename for each of the 600 objContact items it says
ContactItem for each item.
Any ideas?
Tia
Andy
Sub SearchAndReplaceContacts()
On Error Resume Next
'Const olFolderContacts = 10
'Set objOutlook = CreateObject("Outlook.Application")
Dim objNamespace As NameSpace
Set objNamespace = Application.GetNamespace("MAPI")
Dim colContacts As Items
Set colContacts = objNamespace.GetDefaultFolder(10).Items
'Dim objContact As ContactItem
Dim objContact
Dim i
For Each objContact In colContacts
Debug.Print i & " - " & objContact.FullName & " - " &
objContact.Email1Address _
& " - " & objContact.Email2Address _
& " - " & objContact.Email3Address
'Debug.Print i & TypeName(objContact)
i = i + 1
Next objContact
Debug.Print colContacts.Count & TypeName(objContact)
End Sub