![]() |
| 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. |
|
|||||||
| Tags: 2007, calendar, event, outlook, selectionchange |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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
|
|||
|
|||
|
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 | |
|
|
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 |