VSTO: Cannot open another Excel file while the first file is blocked by a modal from the add-in

We cannot open another Excel file and the first file is locked by a modal from our add-in. Closing the dialog cancels the opening of all pending files.

The version of Excel is 2007. Is there a programmatic work that will allow Microsoft Excel 2007 to open the second file in a separate window while the first window is waiting for an add-in to be retrieved from a modal dialog?

NB: This behavior seems to apply to Excel's own dialog boxes as well.

+2


source to share


3 answers


No, this is an architectural limitation of how Excel Automation Server is written. There's only one thread serving the automation queue - if Excel is at the top of the call stack and something blocks below, new calls to the automation server are queued until it returns.



+3


source


I am currently upgrading our application to Excel 2007 and VS 2010 (targeting .NET 4.0) and I noticed that if you are using CustomTaskPane it works on a different thread. I have an addin that creates a taskbar that launches a modal form, and from that form I add a new book. This seems to work without issue. If I run the modal form directly from the add-in, I get the same problem you described. I'm not sure if this will work in .NET 3.5 or 2.0, but it's worth it. (More on CustomTaskPane: http://msdn.microsoft.com/en-us/library/aa942864(VS.100).aspx )



+1


source


The only option I can use is to create a new instance of Excel.Application from your admin and use that instance to open pending files. Not perfect, but as the other answer says, this is a product limitation. (Excel)

+1


source







All Articles