Rinat Abdullin
Rinat Abdullin

Reputation: 23552

VSTO: can't open another Excel file, while first file is blocked by modal window from Add-in

We can't open another Excel file, while first file is blocked by modal window from our Add-in. Closing the dialog window unfreezes all pending file opens.

Excel version is 2007. Is there a programmatic work around, that would allow Microsoft Excel 2007 to open the second file in a separate window, while first window is waiting for the Add-in to get out of the modal dialog window?

NB: it seems that this behavior applies to Excel's own dialog windows as well.

Upvotes: 2

Views: 1164

Answers (3)

Anonymous Type
Anonymous Type

Reputation: 3061

Only option I can think of off-hand is to create a new instance of Excel.Application from within your addin and use this instance to open the pending files. Not ideal but as other answer says it is a limitation of the product. (Excel)

Upvotes: 1

Erick
Erick

Reputation: 1246

I'm currently upgrading our application to Excel 2007 and VS 2010 (targeting .NET 4.0) and I did notice that you if you are using a CustomTaskPane, it seems to be running on a different thread. I have an addin that creates a task pane which launches a modal form and from that form I add a new workbook. It seems to work without a problem. If I launch the modal form directly from the addin I do 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 a shot. (More on CustomTaskPane: http://msdn.microsoft.com/en-us/library/aa942864(VS.100).aspx)

Upvotes: 2

nitzmahone
nitzmahone

Reputation: 13940

No- it's an architectural limitation of the way Excel's automation server is written. There's only one thread servicing the automation queue- if Excel is at the top of the call stack and anything is blocking lower down, new calls to the automation server are queued until it comes back.

Upvotes: 3

Related Questions