A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

expression which is not collaction type error in vb.net



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 23rd 06, 08:29 AM posted to microsoft.public.outlook.program_vba
Sanjay
external usenet poster
 
Posts: 6
Default 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

Ads
  #2  
Old February 23rd 06, 04:55 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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


  #3  
Old February 24th 06, 05:15 AM posted to microsoft.public.outlook.program_vba
Sanjay
external usenet poster
 
Posts: 6
Default 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.

  #4  
Old February 24th 06, 03:48 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 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.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I sort events on my calendar by label or type? djrtowle Outlook - Calandaring 5 August 15th 06 10:16 PM
The current document type cannot be sent as mail Teddy Banks Outlook Express 12 March 31st 06 03:20 AM
How can I print to a dayrunner type calendar lou Outlook - Calandaring 1 February 10th 06 10:54 AM
how do i find type of mail opened? Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 February 6th 06 09:13 PM
Open an attachement of type olEmbeddeditem Nuno Add-ins for Outlook 3 January 16th 06 06:09 PM


All times are GMT +1. The time now is 08:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.