Thread: Address Book
View Single Post
  #24  
Old June 6th, 2004, 07:45 PM
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: n/a
Default Address Book

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
http://www.outlookcode.com/jumpstart.aspx


"Roy" wrote in message
...
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

colContacts is storing anything or if it is coming up empty because it
cannot find the default Contacts folder. I especially want to see what
colContacts is storing.

For 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

my Contacts folder. IF the list matches, then I have eliminated this line
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
http://www.outlookcode.com/jumpstart.aspx


"Roy" wrote in message
...
Hello Sue,
Don't know if you are tyring to figure out the problem I am having

or have
simply given up on it.
In your line of code,

Set colContacts = objNS.GetDefaultFolder(olFolderContacts).Items
How can I get to see what Contact Folder the system is bringing

up. I
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.
Thanks,
Roy.