Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / July 2007

Tip: Looking for answers? Try searching our database.

OOM 2003: can't identify selected folder from Selection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kelmen - 24 Jul 2007 08:16 GMT
Greeting, I'm working on add-in using C# and Outlook Object Model.

At one event I need to identify the selection items. But for case when
I selected a folder:
- the Selection.Count give me 1, ok.
- but getting the item out, I can't type cast it to MAPIfolder!
- I have no problem if the items are ContactItem!

Am I missing something, or its another OOM bug again?
SvenC - 24 Jul 2007 08:48 GMT
Hi,

> At one event I need to identify the selection items. But for case when
> I selected a folder:
[quoted text clipped - 3 lines]
>
> Am I missing something, or its another OOM bug again?

I do not think that the Selection collection will contain folder elements.
Whenever you select a folder you can see that the topmost element of that
folder is also selected. I guess that causes the count property to be 1 from
the beginning.
Depending on the view of the folder you might have no visual feedback that
one element of that folder is selected.

To get the folder of the selection you could use the Parent property of the
first element of the selection.
Try this in VBA:

 Dim o As Object
 Set o = ActiveExplorer.Selection.Item(1)
 Debug.Print TypeName(o)
 Debug.Print TypeName(o.Parent)

That should display an item type like MailItem, followed by MAPIFolder

--
SvenC
Ken Slovak - [MVP - Outlook] - 24 Jul 2007 14:27 GMT
ActiveExplorer.CurrentFolder would also return the MAPIFolder that's
current.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

> Hi,
>
[quoted text clipped - 26 lines]
> --
> SvenC
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.