S
Sue Mosher [MVP-Outlook]
Repeating: When in doubt, check the object browser: Press ALt+F11 to open
the VBA environment in Outlook, then press F2. Switch from <All Libraries>
to Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.
If you looked up the Items collection in the object browser, you'd see that
it has a Count property that you can use to determine whether there are any
items in the folder.
You can iterate any Items collection with a For Each ... Next loop:
Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
If colContacts.Count > 0 Then
For Each objItem in colContacts
Debug.Print objItem.Subject
Next
Else
Debug.Print "No contacts in default folder"
End If
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
cannot find the default Contacts folder. I especially want to see what
colContacts is storing.
of code from debugging. But if the conetnts of colContacts is coming up
empty, then I know I have to do further research on this line of code.
the VBA environment in Outlook, then press F2. Switch from <All Libraries>
to Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.
If you looked up the Items collection in the object browser, you'd see that
it has a Count property that you can use to determine whether there are any
items in the folder.
You can iterate any Items collection with a For Each ... Next loop:
Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
If colContacts.Count > 0 Then
For Each objItem in colContacts
Debug.Print objItem.Subject
Next
Else
Debug.Print "No contacts in default folder"
End If
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
colContacts is storing anything or if it is coming up empty because itRoy said:So then, colContacts stores all of the items in my contacts folder.
How can I print colContacts to the Immediate Folder. I want to see if
cannot find the default Contacts folder. I especially want to see what
colContacts is storing.
my Contacts folder. IF the list matches, then I have eliminated this lineFor example, if colContacts is empty I can then see why "Set objContact = olContacts.Find(strFind)"
would be spitting out an error.
I would also like to compare colContacts information to the list I have in
of code from debugging. But if the conetnts of colContacts is coming up
empty, then I know I have to do further research on this line of code.
Thanks.
----- Sue Mosher [MVP-Outlook] wrote: -----
Namespace.GetDefaultFolder() returns your default Contacts folder, i.e. the
one in the hierarchy whose top level is labeled Outlook Today, the same one
where your default Inbox resides. The Items collection is the collection of
all items in that folder.
When in doubt, check the object browser: Press ALt+F11 to open the VBA
environment in Outlook, then press F2. Switch from <All Libraries> to
Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
or haveRoy said:Hello Sue,
simply given up on it.up. ISet colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
imagine this code is bringing up all the contacts in my contact folder. IF
it is not, can you please explain what that line of code is doing.