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 » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , ,

SelectionChange event in Outlook 2007 calendar





 
 
Thread Tools Display Modes
  #1  
Old April 18th 08, 01:57 PM posted to microsoft.public.outlook.program_addins
Marcin
external usenet poster
 
Posts: 9
Default SelectionChange event in Outlook 2007 calendar

Hi,
I am writing an add-in, that does few things, with emails and appointments
on the calendar. I need to read every item once it it selected by user,
since ItemLoad fires only once, and I got to get Item's few properties upon
it's selection.
Handling MailItems this way works just fine, but I encountered strange
behaviour. Switching to calendar, and selecting any existing appointment,
makes SelectionChange event be triggered multiple times, instead of just one.
Any idea why ?
My event code :
void ThisAddIn_SelectionChange()
{
try
{
if (Application.ActiveExplorer().Selection.Count 0)
{
if (Application.ActiveExplorer().Selection[1] is
Outlook.MailItem)
{
Outlook.MailItem Item =
(Outlook.MailItem)Application.ActiveExplorer().Sel ection[1];
this.OutlookItem = (Outlook.MailItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.AppointmentItem)
{
Outlook.AppointmentItem Item =
(Outlook.AppointmentItem)Application.ActiveExplore r().Selection[1];
this.OutlookItem = (Outlook.AppointmentItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.MeetingItem)
{
Outlook.MeetingItem Item =
(Outlook.MeetingItem)Application.ActiveExplorer(). Selection[1];
this.OutlookItem = (Outlook.MeetingItem)Item;
}
// set certain properties for the add-in, no matter what
type of Item is being dealt with
this.setProperties();
}
}
catch (Exception ex)
{
//do nothing yet
}
}

The .setProperties() does same kind of check that is :


Ads
  #2  
Old April 18th 08, 02:13 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,426
Default SelectionChange event in Outlook 2007 calendar

When switching a folder you are changing Selection since the
ActiveExplorer().CurrentFolder object is changing. Then when you select one
or more items Selection will change again. Is that what you're seeing?

--
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


"Marcin" wrote in message
...
Hi,
I am writing an add-in, that does few things, with emails and appointments
on the calendar. I need to read every item once it it selected by user,
since ItemLoad fires only once, and I got to get Item's few properties
upon
it's selection.
Handling MailItems this way works just fine, but I encountered strange
behaviour. Switching to calendar, and selecting any existing appointment,
makes SelectionChange event be triggered multiple times, instead of just
one.
Any idea why ?
My event code :
void ThisAddIn_SelectionChange()
{
try
{
if (Application.ActiveExplorer().Selection.Count 0)
{
if (Application.ActiveExplorer().Selection[1] is
Outlook.MailItem)
{
Outlook.MailItem Item =
(Outlook.MailItem)Application.ActiveExplorer().Sel ection[1];
this.OutlookItem = (Outlook.MailItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.AppointmentItem)
{
Outlook.AppointmentItem Item =
(Outlook.AppointmentItem)Application.ActiveExplore r().Selection[1];
this.OutlookItem = (Outlook.AppointmentItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.MeetingItem)
{
Outlook.MeetingItem Item =
(Outlook.MeetingItem)Application.ActiveExplorer(). Selection[1];
this.OutlookItem = (Outlook.MeetingItem)Item;
}
// set certain properties for the add-in, no matter
what
type of Item is being dealt with
this.setProperties();
}
}
catch (Exception ex)
{
//do nothing yet
}
}

The .setProperties() does same kind of check that is :



  #3  
Old April 18th 08, 02:44 PM posted to microsoft.public.outlook.program_addins
Marcin
external usenet poster
 
Posts: 9
Default SelectionChange event in Outlook 2007 calendar

No, that's no what I meant. That would be a normal behaviour.
What I mean is following.
1. open outlook, by default it selects first email in the default folder
2. switch to calendar, with breakpoints on the beginning, and every if
clause of SelectionChange event.
3. it continuously enters the event handler, recognises _lack_ of any
selection, exists first if clause without any action, re-enters event handler
and so on. Exit to Outlook is only possible with disabling breakpoints.
Re-enabling them, and selecting any existing item on the calendar (item, not
empty date), causes exactly same behaviour. Since exception handling is in
place ... and no exception gets thrown unhandled, it seems a bit weird to me.


Regards

MArcin

"Ken Slovak - [MVP - Outlook]" wrote:

When switching a folder you are changing Selection since the
ActiveExplorer().CurrentFolder object is changing. Then when you select one
or more items Selection will change again. Is that what you're seeing?

--
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


"Marcin" wrote in message
...
Hi,
I am writing an add-in, that does few things, with emails and appointments
on the calendar. I need to read every item once it it selected by user,
since ItemLoad fires only once, and I got to get Item's few properties
upon
it's selection.
Handling MailItems this way works just fine, but I encountered strange
behaviour. Switching to calendar, and selecting any existing appointment,
makes SelectionChange event be triggered multiple times, instead of just
one.
Any idea why ?
My event code :
void ThisAddIn_SelectionChange()
{
try
{
if (Application.ActiveExplorer().Selection.Count 0)
{
if (Application.ActiveExplorer().Selection[1] is
Outlook.MailItem)
{
Outlook.MailItem Item =
(Outlook.MailItem)Application.ActiveExplorer().Sel ection[1];
this.OutlookItem = (Outlook.MailItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.AppointmentItem)
{
Outlook.AppointmentItem Item =
(Outlook.AppointmentItem)Application.ActiveExplore r().Selection[1];
this.OutlookItem = (Outlook.AppointmentItem)Item;
}
if (Application.ActiveExplorer().Selection[1] is
Outlook.MeetingItem)
{
Outlook.MeetingItem Item =
(Outlook.MeetingItem)Application.ActiveExplorer(). Selection[1];
this.OutlookItem = (Outlook.MeetingItem)Item;
}
// set certain properties for the add-in, no matter
what
type of Item is being dealt with
this.setProperties();
}
}
catch (Exception ex)
{
//do nothing yet
}
}

The .setProperties() does same kind of check that is :




  #4  
Old April 18th 08, 06:15 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 3,426
Default SelectionChange event in Outlook 2007 calendar

Does it do the same thing if instead of breakpoints you put
Debug.WriteLine() or MessageBox.Show() statements?

--
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


"Marcin" wrote in message
...
No, that's no what I meant. That would be a normal behaviour.
What I mean is following.
1. open outlook, by default it selects first email in the default folder
2. switch to calendar, with breakpoints on the beginning, and every if
clause of SelectionChange event.
3. it continuously enters the event handler, recognises _lack_ of any
selection, exists first if clause without any action, re-enters event
handler
and so on. Exit to Outlook is only possible with disabling breakpoints.
Re-enabling them, and selecting any existing item on the calendar (item,
not
empty date), causes exactly same behaviour. Since exception handling is
in
place ... and no exception gets thrown unhandled, it seems a bit weird to
me.


Regards

MArcin


  #5  
Old April 21st 08, 07:06 AM posted to microsoft.public.outlook.program_addins
Marcin
external usenet poster
 
Posts: 9
Default SelectionChange event in Outlook 2007 calendar

Yes it does, at least with MessageBoxes. Haven't tried yet with printing
debug, but will do so soon and will post results.

"Ken Slovak - [MVP - Outlook]" wrote:

Does it do the same thing if instead of breakpoints you put
Debug.WriteLine() or MessageBox.Show() statements?

--
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


"Marcin" wrote in message
...
No, that's no what I meant. That would be a normal behaviour.
What I mean is following.
1. open outlook, by default it selects first email in the default folder
2. switch to calendar, with breakpoints on the beginning, and every if
clause of SelectionChange event.
3. it continuously enters the event handler, recognises _lack_ of any
selection, exists first if clause without any action, re-enters event
handler
and so on. Exit to Outlook is only possible with disabling breakpoints.
Re-enabling them, and selecting any existing item on the calendar (item,
not
empty date), causes exactly same behaviour. Since exception handling is
in
place ... and no exception gets thrown unhandled, it seems a bit weird to
me.


Regards

MArcin



  #6  
Old April 21st 08, 09:35 AM posted to microsoft.public.outlook.program_addins
Marcin
external usenet poster
 
Posts: 9
Default SelectionChange event in Outlook 2007 calendar

With Debug.WriteLine() it seems to be handling it only once, as it should be
done. Since all the exceptions are handled ... seems I need to get back to
debugging :-(

Had a deeper look at SelectionChange event ... what I noticed is that it
fires everytime I switch between applications, which messes up my application
logic then ...

Thanks Ken

marcin

"Ken Slovak - [MVP - Outlook]" wrote:

Does it do the same thing if instead of breakpoints you put
Debug.WriteLine() or MessageBox.Show() statements?

--
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


"Marcin" wrote in message
...
No, that's no what I meant. That would be a normal behaviour.
What I mean is following.
1. open outlook, by default it selects first email in the default folder
2. switch to calendar, with breakpoints on the beginning, and every if
clause of SelectionChange event.
3. it continuously enters the event handler, recognises _lack_ of any
selection, exists first if clause without any action, re-enters event
handler
and so on. Exit to Outlook is only possible with disabling breakpoints.
Re-enabling them, and selecting any existing item on the calendar (item,
not
empty date), causes exactly same behaviour. Since exception handling is
in
place ... and no exception gets thrown unhandled, it seems a bit weird to
me.


Regards

MArcin



 




Thread Tools
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
2007 Calendar Event not working well with Entourage Brandoni Outlook - Calandaring 0 November 6th 07 01:56 AM
an event or appointment in the calendar in outlook 2007 does not w izzy Outlook - Calandaring 3 June 21st 07 01:47 AM
selectionchange event for inspector? jiun Outlook and VBA 1 January 2nd 07 06:35 AM
SelectionChange Event in Outlook Calender lg Add-ins for Outlook 6 October 4th 06 03:09 PM
SelectionChange Event A. Blundon Outlook and VBA 2 February 27th 06 07:52 PM


All times are GMT +1. The time now is 02:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Personal Loan - Myspace Layouts - Loans - Carcasherdotcom Seocontest - Refinance