VSTO:无法打开另一个 Excel 文件,而第一个文件被加载项的模式窗口阻止
我们无法打开另一个 Excel 文件,而第一个文件被我们的加载项中的模式窗口阻止。关闭对话框窗口将解冻所有打开的挂起文件。
Excel 版本是 2007。是否有编程解决方法,允许 Microsoft Excel 2007 在单独的窗口中打开第二个文件,而第一个窗口正在等待加载项退出模式对话框窗口?
注意:这种行为似乎也适用于 Excel 自己的对话框窗口。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,这是 Excel 自动化服务器编写方式的体系结构限制。只有一个线程为自动化队列提供服务 - 如果 Excel 位于调用堆栈的顶部并且有任何内容阻塞了较低的位置,则对自动化服务器的新调用将排队,直到它返回。
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.
我目前正在将我们的应用程序升级到 Excel 2007 和 VS 2010(针对 .NET 4.0),我确实注意到,如果您使用的是 CustomTaskPane,它似乎正在不同的线程上运行。我有一个插件,它创建一个任务窗格,启动一个模式表单,并从该表单中添加一个新的工作簿。它似乎工作没有问题。如果我直接从插件启动模态表单,我确实会遇到您所描述的相同问题。我不确定这是否适用于 .NET 3.5 或 2.0,但值得一试。 (有关 CustomTaskPane 的更多信息:http://msdn.microsoft。 com/en-us/library/aa942864(VS.100).aspx)
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)
我能立即想到的唯一选择是从您的外接程序中创建一个新的 Excel.Application 实例,并使用该实例打开待处理的文件。不理想,但正如其他答案所说,这是产品的限制。 (Excel)
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)