Conflict between Word and Outlook

Hi, I hope you guys can help me with this problem:

I have a couple of VSTO customized Word Templates that create Outlook objects as part of their normal functionality.

When I close and reopen this templates, the logic in the document behaves in a really weird way: Some controls won't work, some initial events are skipped, basically the action pane becomes useless...

I have seen this kind of problem before, caused by the Word instance that Outlook creates to edit mail, appointments, etc. It gets solved by closing the extra Word process in the Task Manager or by closing Outlook completely, but that's something that a normal user may not want or be able to do.

My question is, how can I solve this kind of problem wthout having to turn off Outlook's option of using Word as the default editor (The people using the solution are very fond of this option and won't let it go without a fight).

Thanks for reading, any help is welcome!




Answer this question

Conflict between Word and Outlook

  • MobileApps

    Update: Hi, I was about to post my problem on the support page, when I saw that someone else has exactly the same problem:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=436792&SiteID=1&mode=1

    I posted:

  • cuhkwilliam

    Daniel;

    are you by any chance using VstoSmartTags.Add in your application

    I've been trying to pare my application down to something smaller, and so far, eliminating VstoSmartTags.Add has been the only change I've made that will stop the error from occuring....

    Richard


  • itgold

    Thanks for your answer Kathleen, but I'm calling Dispose on every single Action Pane Control, and even on DataSets, that my app creates, but I still get the error. (Should I call dispose on every control contained inside the Action Panes ).

    I do have a WebBrowser control on one of my Actions Pane Control that I think may be causing the problem, I'm calling Dispose on it too, but I don't think that's working as it's supposed to.

    Actually (and maybe it has something to do with the problem at hand), when I try to close the Workbook by code, I get an strange "Thread Abort Exception" that seems to be related to that same WebBrowser Control...

    Anyway, I'll try and post this on the Product Feedback page, thanks for the link, and thanks for trying to help me.



  • shhh

    Hi Daniel,

    I haven't given up, I just didn't have an answer yet.

    One other possibility is that is you're showing any Windows Forms in your application, you'll want to make sure you explicitly call dispose on the form prior to closing the document.

    If this doesn't solve your problem, I would suggest that you file a bug via the MSDN product feedback center: http://lab.msdn.microsoft.com/productfeedback/.   

    Kathleen McGrath



  • KenWilson

    It appears that we've been struggling with the same problem (http://forums.microsoft.com/msdn/ShowPost.aspx postid=533354&isthread=true&siteid=1)

    I didn't identify with it at first because I wasn't interacting with outlook, but word is the default editor for outlook, and when I close outlook the problem resolves itself.

    I also will try to isolate the problem, but as intermittent as it is, it could take a very long time.

    Richard


  • Ben Enfield

    Daniel,

    I was trying to repro your problem on RTM version of VSTO 2005 and could not. The textboxes I placed into the ActionsPane behaved just fine when I was re-opening the document in the same WINWORD process. Are you sure you are not using Beta2 version of the product - this is the one you could have experienced some of the problems you are describing.

    Can you help me repro this on my machine I will need exact steps on how to get into the state you are describing - then I might help you out with this.

    Thanks



  • JJIII

    Hi,

    It sounds like it might be caused by not releasing the reference to the Outlook objects that you're creating from the template.  You should be sure to release all references to Outlook when you close the template. 

    To check this, be sure there are no instances of Outlook running, then open your template and have the template create the Outlook objects (thus opening Outlook). Next, close your template. If Windows Task Manager shows that the OUTLOOK.EXE process is still running, then you know that you're not properly releasing references to Outlook.

    Let us know if this helped!

    Kathleen McGrath



  • parameswaranpramod

    Hi Daniel,

    Can you provide some of the code you're using to create and release the Outlook objects This would be helpful for us to reproduce the problem and see if we can help find a resolution.

    Kathleen McGrath



  • jkenny

    Hi Misha,

    I'm using the RTM.050727-4200 version. My application is quite peculiar, here is what it does:

    1. I have 10 Actions Pane Controls (I'll call them APs from now on), most of them are referenced as "friend withevents" so I can fire events that allow me to apply business rules and add or remove the controls from the Pane.
    2. I have many DataTables used to retrieve and update information from a Web Service.
    3. The first AP implements a Picture Box that can open a Web Page by means of raising an event that my ThisDocument.vb handles using System.Diagnostics.Process
    4. The second AP (and I think this is the one causing the problem) has a WebBrowser control. It navigates to a ASP.NET page that responds with a Window.External javascript function that the AP uses to raise an event.
      The class imports System.Runtime.InteropServices and is <ComVisible(True)>. It also call it's dispose method as soon as I don't need it anymore.
    5. The third AP holds a couple of Radio Buttons that fire another event to load the next AP and fill a ComboBox with the results of a Web Service response (using a DataTable.Merge).
    6. The fourth AP only shows the ComboBox, so the user can select which data to load form the DataBase.
    7. The fifth one presents the user a series of databinded comboboxes, numeric updowns, radio buttons, Checklist controls, etc... it also sets the mouse cursor to "WaitCursor" and sets a text on the Status Bar (using the code: Globals.ThisDocument.Application.StatusBar = "Please Wait..." and System.Windows.Forms.Cursor.Current = Cursors.WaitCursor).
      Before actually loading the AP, I fill many DataTables (for the comboboxes), I use many Select Case statements and add DataBindings connecting the minimum and maximum values of 3 Numeric UpDowns.
    8. In my testing, as soon as this AP loads, the problem appears. If I close the document before loading this AP, the next time I open the doc everything works fine!
    9. The other APs are similar to the last one.

    I'll keep testing to see if I can isolate the problem, I'd really appreciate any help you can give me.



  • sivakumarhtsl

    Word as an Email Editor in Office 2003 is not good for development, Outlook Events dont fire as you may expect and or at all :(

    We actually have code to explain to the user to disable this, Outlook 2007 has rectified these issues as well as removing the Option to "Not use Word" so word is the Email Editor. But this is isolated as a component that runs within Outlook and not Word as a Process so all of the inspectors work as well as supporting the Send events etc etc.

    Hope this helps as likely to be the event firing order.



  • herd

    Hi, thanks for answering, I really appreciate it, but that's not exactly what's happening. When I finish using the object, the Outlook process does indeed disappear from the task manager.

    The real problem is when Outlook is running and it creates a Word instance that keeps on running (it actually doesn't matter if I open Outlook by code or if the user does it by himself, all that my application needs to fail is Outlook with it's own instance of Word running)

    I have done some testing, and this is exactly what happens:

    1) Outlook is running and creates it's own Word process (you can see both in task manager, but only Outlook is visible to the user).

    2) I load my customized Word document and use it without problems.

    3) I quit Word the usual way, but the Winword process that Outlook created is still running in Task Manager.

    4) I reopen the document to use it again, but it doen't work anymore, at least not how it's supposed to...

    My only guess is that the first time that I load the document, the logic gets "stuck" or "cached" into Outlook's Word instance, and doesn't get unloaded. When I load the document again, it uses the same cache, including stuff that was left in system memory, and that "confuses" my customization.

    Any ideas on how to fix this (As I said, the user doesn't want to close Outlook everytime he uses my document, and I can't trust him to use Task Manager to kill the Winword process manually...).

    Thanks again,



  • jazjef

    Hi Mike, thanks for your answer.

    Actually this problem isn't directly related to Outlook. It's just a problem of having a running instance of Word (and that just happens to be caused sometimes by Outlook, but may be caused by other situations) that doesn't get released between customization loads.

    I think I have fixed the problem, but I haven't been able to test it. Since I was using a WebBrowser control in an action pane, I was calling it's dispose method on the Shutdown event of the Workbook. It seems that the webbrowser control won't get disposed if the dispose method gets called from a different thread than the one in which it was created... so I had to call dispose on it as soon as I stopped using it, right in the same Actions Pane.

    It's good to know that Office 2007 fixes Outlook problems though.



  • MrHeckles

    That would be great if you could isolate the problem first.

  • MR SeeQL

    Hi Kathleen, thanks for not giving up on me!

    Here's the code that I use to work with the Outlook objects, but I don't think that it will be of any help. As I wrote on the last post, I discovered that this "strange behaviour" occurs even when my document's code isn't calling Outlook... it is caused by merely having Outlook (and Outlook's own Word process) running in the client machine at the time of using the document's logic :(

    Dim MyOutlook As New Outlook.Application
    Dim oNS As Outlook.NameSpace = MyOutlook.GetNamespace("mapi")
    oNS.Logon("", , False, True)
    Dim MyA As AppointmentItem
    MyA = MyOutlook.CreateItem(OlItemType.olAppointmentItem)
    ...


    MyA.Save()

    MyA.Display()
    MyOutlook = Nothing
    oNS = Nothing
    MyA = Nothing

    This code, for instance, is not used in the document that doesn't work right. It's in a different document that, at first glance, I thought was causing the problem... but know I'm sure it's not.

    I'm really sorry if I'm confusing you, hope you can still help me, thanks



  • Conflict between Word and Outlook