![]() |
| 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: 2003, 2007, addin, migrating, problem |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hello, I am trying to migrate an application thatwas written for Outlook 2003 to work with 2007. I am having a particularly difficult time with an issue documented he http://support.microsoft.com/kb/929593 . The issue is that Item.Close can no longer be called from the Inspector.Close event. In the 2003 version of my program, the code catches the Item.Close event, asks the user if they wanted to save their changes and then 'does some stuff' if they say yes, 'does some other stuff' if they say No, and does something completely different if they cancel. When the function is done, Item.Close(olDiscard) is called because my application had already handled the save (if necessary). If I didn't do it this way, the user would get two "do you want to save" prompts: one from me, and one from Outlook. Now, in Outlook 2007, it appears that I can no longer call Item.Close from the Item.Close event. Unfortunately, if I skip this call, the item seems to somehow get 'stuck' in Outlook, and when the application is closed, Outlook asks if I want to save changes for an item that is no longer visible & should have been closed already. Is there another way to accomplish what I am trying to do? In other words, I need to replace the Item.Close event with my own code which asks the user if they want to save, and bypasses Outlook's prompt for the same. Thank you, Jon Rizzo Langan Engineering & Environmental Services |
| Ads |
|
#2
|
|||
|
|||
|
Outlook 2003 SP3 also implements the same restriction.
Set up a timer to fire shortly after the event handler ends and call Close in the timer elapsed event handler. -- 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 "Jon Rizzo" wrote in message ... Hello, I am trying to migrate an application thatwas written for Outlook 2003 to work with 2007. I am having a particularly difficult time with an issue documented he http://support.microsoft.com/kb/929593 . The issue is that Item.Close can no longer be called from the Inspector.Close event. In the 2003 version of my program, the code catches the Item.Close event, asks the user if they wanted to save their changes and then 'does some stuff' if they say yes, 'does some other stuff' if they say No, and does something completely different if they cancel. When the function is done, Item.Close(olDiscard) is called because my application had already handled the save (if necessary). If I didn't do it this way, the user would get two "do you want to save" prompts: one from me, and one from Outlook. Now, in Outlook 2007, it appears that I can no longer call Item.Close from the Item.Close event. Unfortunately, if I skip this call, the item seems to somehow get 'stuck' in Outlook, and when the application is closed, Outlook asks if I want to save changes for an item that is no longer visible & should have been closed already. Is there another way to accomplish what I am trying to do? In other words, I need to replace the Item.Close event with my own code which asks the user if they want to save, and bypasses Outlook's prompt for the same. Thank you, Jon Rizzo Langan Engineering & Environmental Services |
|
#3
|
|||
|
|||
|
Thank you for the suggestion. I moved the 'close' call to a timer event, so it now saves and closes properly. Unfortunately, when Outlook exits, it (Outlook) still asks "Do you want to save changes". There aren't any open inspectors, so I can't explain why this message is appearing. "Ken Slovak - [MVP - Outlook]" wrote: Outlook 2003 SP3 also implements the same restriction. Set up a timer to fire shortly after the event handler ends and call Close in the timer elapsed event handler. -- 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 "Jon Rizzo" wrote in message ... Hello, I am trying to migrate an application thatwas written for Outlook 2003 to work with 2007. I am having a particularly difficult time with an issue documented he http://support.microsoft.com/kb/929593 . The issue is that Item.Close can no longer be called from the Inspector.Close event. In the 2003 version of my program, the code catches the Item.Close event, asks the user if they wanted to save their changes and then 'does some stuff' if they say yes, 'does some other stuff' if they say No, and does something completely different if they cancel. When the function is done, Item.Close(olDiscard) is called because my application had already handled the save (if necessary). If I didn't do it this way, the user would get two "do you want to save" prompts: one from me, and one from Outlook. Now, in Outlook 2007, it appears that I can no longer call Item.Close from the Item.Close event. Unfortunately, if I skip this call, the item seems to somehow get 'stuck' in Outlook, and when the application is closed, Outlook asks if I want to save changes for an item that is no longer visible & should have been closed already. Is there another way to accomplish what I am trying to do? In other words, I need to replace the Item.Close event with my own code which asks the user if they want to save, and bypasses Outlook's prompt for the same. Thank you, Jon Rizzo Langan Engineering & Environmental Services |
|
#4
|
|||
|
|||
|
Sounds like something wasn't released. Did you call Marshal.ReleaseComObject
on the Inspector related objects and wait for the garbage collector to finalize? -- 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 "Jon Rizzo" wrote in message ... Thank you for the suggestion. I moved the 'close' call to a timer event, so it now saves and closes properly. Unfortunately, when Outlook exits, it (Outlook) still asks "Do you want to save changes". There aren't any open inspectors, so I can't explain why this message is appearing. |
|
#5
|
|||
|
|||
|
I am releasing both the item and the inspector in a loop to ensure that all references are released: Do refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj) Loop While (refsLeft 0) "Ken Slovak - [MVP - Outlook]" wrote: Sounds like something wasn't released. Did you call Marshal.ReleaseComObject on the Inspector related objects and wait for the garbage collector to finalize? -- 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 "Jon Rizzo" wrote in message ... Thank you for the suggestion. I moved the 'close' call to a timer event, so it now saves and closes properly. Unfortunately, when Outlook exits, it (Outlook) still asks "Do you want to save changes". There aren't any open inspectors, so I can't explain why this message is appearing. |
|
#6
|
|||
|
|||
|
That save message would only appear if there are still live references
somewhere to your objects. -- 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 "Jon Rizzo" wrote in message ... I am releasing both the item and the inspector in a loop to ensure that all references are released: Do refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj) Loop While (refsLeft 0) |
|
#7
|
|||
|
|||
|
Jon Rizzo wrote:
I am releasing both the item and the inspector in a loop to ensure that all references are released: Do refsLeft = System.Runtime.InteropServices.Marshal.ReleaseCom Object(obj) Loop While (refsLeft 0) I hope you have a safety valve such as a counter set to some comfortably big number for example, so that the loop doesn't get stuck in perpetuity. Maybe even every 5 loops do a DoEvents. -mhd |
|
#8
|
|||
|
|||
|
I am really stumped on this one. My problem seems to stem from the fact that my code is not explicitly creating any new com objects (only grabbing objects opened by the user), so I'm not sure which pointers need to be released. I never received this message in Outlook 2003. I have isolated the problem down to a fairly simple buildable example. I know that it is a lot to ask, but would you mind taking a look at the sample to see if you can tell what's I'm missing? All you need to do to demonstrate the problem is build the program, run outlook, open a contact, close the contact (without saving) and then close outlook. Jon "Ken Slovak - [MVP - Outlook]" wrote: That save message would only appear if there are still live references somewhere to your objects. -- 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 "Jon Rizzo" wrote in message ... I am releasing both the item and the inspector in a loop to ensure that all references are released: Do refsLeft = System.Runtime.InteropServices.Marshal.ReleaseComO bject(obj) Loop While (refsLeft 0) |
|
#9
|
|||
|
|||
|
Is that code too long to post here? If so send me a copy, but I can't
promise when I'll get a chance to review it, my time is pretty booked up. -- 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 "Jon Rizzo" wrote in message ... I am really stumped on this one. My problem seems to stem from the fact that my code is not explicitly creating any new com objects (only grabbing objects opened by the user), so I'm not sure which pointers need to be released. I never received this message in Outlook 2003. I have isolated the problem down to a fairly simple buildable example. I know that it is a lot to ask, but would you mind taking a look at the sample to see if you can tell what's I'm missing? All you need to do to demonstrate the problem is build the program, run outlook, open a contact, close the contact (without saving) and then close outlook. Jon |
|
#10
|
|||
|
|||
|
Thanks, ken. It's not terribly long, but it contains 2 classes, so it might
be a bit confusing to post here. I emailed it to your mvps.org email address. Thank you!! Jon "Ken Slovak - [MVP - Outlook]" wrote: Is that code too long to post here? If so send me a copy, but I can't promise when I'll get a chance to review it, my time is pretty booked up. -- 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 "Jon Rizzo" wrote in message ... I am really stumped on this one. My problem seems to stem from the fact that my code is not explicitly creating any new com objects (only grabbing objects opened by the user), so I'm not sure which pointers need to be released. I never received this message in Outlook 2003. I have isolated the problem down to a fairly simple buildable example. I know that it is a lot to ask, but would you mind taking a look at the sample to see if you can tell what's I'm missing? All you need to do to demonstrate the problem is build the program, run outlook, open a contact, close the contact (without saving) and then close outlook. Jon |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deploy 2003 vsto addin on outlook 2007 problem | lokesh | Add-ins for Outlook | 17 | April 17th 08 05:36 PM |
| Migrating from Outllok 2003 to 2007 | lwlittle | Outlook - Installation | 3 | February 11th 08 05:32 PM |
| Migrating AddIn from VB6 to VB2005 | Thanasis Soltadis | Add-ins for Outlook | 2 | October 4th 07 04:06 PM |
| Problem with an Addin using IExchExtCommands and Outlook 2007 B2 T | Christophe SAINCLIVIER | Add-ins for Outlook | 2 | October 31st 06 11:38 AM |
| Migrating BCM files from 2003 to 2007 | JimB | Outlook - Installation | 1 | July 16th 06 03:18 PM |