none
Multiple Winword.exe's RRS feed

  • Question

  • I'm writing a Word AddIn and have begun testing AddIn startup scenarios.  Everything is working well except when I select multiple document files (CTRL-Click) and then RightClick Open the multiple files.  I've noticed in Task Manager that I have multiple Winword.exe's running and my AddIn throws an exception.  Under all other startup scenarios, opening multiple documents all seem to work within a single instance of Winword.exe.  So a couple of questions.

    1.  I always thought that only one instance of Winword.exe was ever allowed to run. True or False??

    2.  If #1 is False (as it seems to be), then are there any ramifications to my AddIn if multiple instances are running.  I'm throwing an exception since both my AddIn's are attempting to open the same file (which I know how to fix).

    Thanks for any clarification you can provide.

    Billwa992

    Thursday, April 7, 2011 8:43 PM

Answers

  • Cindy and Tony,

    Thanks for your replies.

    Cindy - I am running on a default installation of Windows 7 (x64) and Office 2010 (x86), so the Registry command line change has not been done.  Thus, I believe I am running into the "bug" that Tony is refering to.  It's not that hard to reproduce, simply select multiple files and then Open them all with a single RightClick/Open operation.  The Multiple Winword.exe issue does not appear to happen on Windows 7 with Office 2007.  Hope this helps to identify and fix (if necessary).

     

    I've solved my immediate problem, I simply raised this as it was inconsistent with my understanding, and Tony's idea that this is a "bug" satisfies my inquiry.  I'm just getting started with this AddIn and I will probably continue to need the benefit of this body's experience and generosity as I continue my project.

     

    Thanks,  Billwa992

     

     

    • Marked as answer by billwa992 Friday, April 8, 2011 4:10 PM
    Friday, April 8, 2011 4:10 PM

All replies

  • Hi Bill,

    Answer to question 1 is False.

    The answer to question 2 kind of depends on your add-in and you've obviously seen one ramification.

    What has probably happened with your add-in is that you are starting a New Word application without checking if an existing Word application was already running.  Here's a sample of how I check for Excel in one of my Word add-ins that transfers some data to an Excel workbook.

            If Process.GetProcessesByName("EXCEL").Count > 0 Then

                MyXL = Marshal.GetActiveObject("Excel.Application")

            Else

                MyXL = New xApp

                newXl = True

            End If

     

    What happens is if it finds Excel is already running it just attaches Excel to my object. If it's not running it creates a New instance of Excel.

     

    Hope this helps

     


    Regards
    Thursday, April 7, 2011 9:32 PM
  • Hi Bill

    By default, 1 will be true. The actual behavior will, however, depend on the settings in the Registry for winword.exe on the individual machine. The behavior of the commands you see in the right-click menu depend on a DDE command line associated with the executable type and this can be set to always use a command line switch to start a new instance. As I mentioned, by default this is not the case, but the possibility exists.

    This kind of thing used to be easier to see, back when you could set these command lines in Windows through a "Properties" dialog box...

    Have you tried testing on a different machine (preferably one with a default installation)?

    As an Add-in runs in-process, I doubt whether Rich's thought is on-target in this case. It would be unusual for an add-in to start a new process of the application it's running in and if it did so at start-up you'd essentially get an endless loop that would eventually use up all available resources.


    Cindy Meister, VSTO/Word MVP
    Friday, April 8, 2011 6:52 AM
    Moderator
  • This rings a bell - there is an issue with Word 2010 opening multiple instances in the circumstances you describe. As far as I know there is no fix available. If your AddIn(s) want to co-ordinate actions relating to the multiple files, things could get difficult but, for the most part multiple instances can run happily together.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Friday, April 8, 2011 11:15 AM
  • This rings a bell - there is an issue with Word 2010 opening multiple instances in the circumstances you describe. As far as I know there is no fix available. If your AddIn(s) want to co-ordinate actions relating to the multiple files, things could get difficult but, for the most part multiple instances can run happily together.
     


    Interesting, I hadn't encountered this before.

    If multiple instances were a problem, it would theoretically be possible for the add-in to write the various file names somewhere, quit those Word instances, then open the files in the one retained instance, I suppose. The one part I don't know, right off-hand, is how to determine how many instances of Word are running?


    Cindy Meister, VSTO/Word MVP
    Friday, April 8, 2011 3:09 PM
    Moderator
  • Cindy and Tony,

    Thanks for your replies.

    Cindy - I am running on a default installation of Windows 7 (x64) and Office 2010 (x86), so the Registry command line change has not been done.  Thus, I believe I am running into the "bug" that Tony is refering to.  It's not that hard to reproduce, simply select multiple files and then Open them all with a single RightClick/Open operation.  The Multiple Winword.exe issue does not appear to happen on Windows 7 with Office 2007.  Hope this helps to identify and fix (if necessary).

     

    I've solved my immediate problem, I simply raised this as it was inconsistent with my understanding, and Tony's idea that this is a "bug" satisfies my inquiry.  I'm just getting started with this AddIn and I will probably continue to need the benefit of this body's experience and generosity as I continue my project.

     

    Thanks,  Billwa992

     

     

    • Marked as answer by billwa992 Friday, April 8, 2011 4:10 PM
    Friday, April 8, 2011 4:10 PM
  • Hi Cindy,

     

    Well I know it’s definitely doable. In VSTO Word add-ins on 2007 and 2010 you can open another instance of Word, keep it hidden, open “secret” files read, write, whatever, and then quit the special instance. It’s the only way the Visible = False command will work from an existing Word add-in.  You have to create a new Word object.

     

    How that shows up in the Task Manager, I never took the time to investigate.

     

    As for counting the instances of the WINWORD image … this will do it.

    Process.GetProcessesByName("WINWORD").Count

     

    As for its count accuracy in 2007 versus 2010, I can’t say. I know based on my observations, in 2010 it’s correct.

     


    Regards
    Saturday, April 9, 2011 3:34 AM
  • Hi Rich / all

    <<As for counting the instances of the WINWORD image … this will do it.

    Process.GetProcessesByName("WINWORD").Count>>

     

    Right, that would be the missing piece. I've been out of things for a few weeks and obviously my brain cells aren't recalling everything without a little nudge here and there :-)

     

    I was testing on Windows Vista and Word 2007, which would explain why I wasn't repro-ing if this is a Windows 7 / Office 2010 issue. Yep, there it is... Nasty piece of work, that change. How do they expect us to quickly and efficiently exit the application?


    Cindy Meister, VSTO/Word MVP
    • Proposed as answer by BarunSmart Tuesday, June 19, 2012 11:56 AM
    • Unproposed as answer by BarunSmart Tuesday, June 19, 2012 11:56 AM
    Saturday, April 9, 2011 8:02 AM
    Moderator