Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   expression which is not collaction type error in vb.net (http://www.outlookbanter.com/outlook-vba/7492-expression-not-collaction-type-error.html)

Sanjay February 23rd 06 08:29 AM

expression which is not collaction type error in vb.net
 
hi to all

i have code for getting contact folders from outlook. but when i was
colllect all folders name in one variable and then getting for which is
contact folder i use FOR EACH loop. that time it is giving error saying
that that varible is not collection type

i type my code here

Dim oFolder As Outlook.MAPIFolder
Dim colFolders As Outlook.Folders

On Error Resume Next

colFolders = oSourceFolder.Folders
If Not (colFolders Is Nothing) Then

For Each oFolder In colFolders
If colFolders.DefaultItemType = olContactItem Then
'do whatever
End If
'recursive call to SetAllContactFolders.
'repeat until no more subfolders
Call SetAllContactFolders(oFolder)
Next
End If

oFolder = Nothing
colFolders = Nothing

it is giving error at FOR EACH oFolder in ColFolders . so error at
ColFolders.

ok so what's prob is.

thanks


Ken Slovak - [MVP - Outlook] February 23rd 06 04:55 PM

expression which is not collaction type error in vb.net
 
See if it works if you change this line:

If colFolders.DefaultItemType = olContactItem Then

to this:

If oFolder.DefaultItemType = olContactItem Then


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Sanjay" wrote in message
oups.com...
hi to all

i have code for getting contact folders from outlook. but when i was
colllect all folders name in one variable and then getting for which is
contact folder i use FOR EACH loop. that time it is giving error saying
that that varible is not collection type

i type my code here

Dim oFolder As Outlook.MAPIFolder
Dim colFolders As Outlook.Folders

On Error Resume Next

colFolders = oSourceFolder.Folders
If Not (colFolders Is Nothing) Then

For Each oFolder In colFolders
If colFolders.DefaultItemType = olContactItem Then
'do whatever
End If
'recursive call to SetAllContactFolders.
'repeat until no more subfolders
Call SetAllContactFolders(oFolder)
Next
End If

oFolder = Nothing
colFolders = Nothing

it is giving error at FOR EACH oFolder in ColFolders . so error at
ColFolders.

ok so what's prob is.

thanks



Sanjay February 24th 06 05:15 AM

expression which is not collaction type error in vb.net
 
Hi ken

Thanks for reply. Now I have problem with this line not which u have
said.

For Each oFolder In colFolders

In this line it is giving error that "colFolders is not a collection
type". so what i have to use or which type i have to declare for that
solving error.


Ken Slovak - [MVP - Outlook] February 24th 06 03:48 PM

expression which is not collaction type error in vb.net
 
Maybe there are no subfolders? Try testing for oSourceFolder.Folders.Count.

Folders is definitely a collection object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Sanjay" wrote in message
oups.com...
Hi ken

Thanks for reply. Now I have problem with this line not which u have
said.

For Each oFolder In colFolders

In this line it is giving error that "colFolders is not a collection
type". so what i have to use or which type i have to declare for that
solving error.




All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com