简体   繁体   中英

Open and close Workbook or Instance in Excel 2016

We have an Excel Interop COM Add-in that performs the following at some point :

CurrentWorkbook.Close();
//other code
ExcelApplication.Workbooks.Open("B.xls");

Let's say we have 1 workbook A.xls open. Up to Excel 2010, this worked as expected when the code is run: A is closed, and then B.xls is opened. I have read that since Excel 2013, each workbook is opened in its own Excel instance. Yet, even with Excel 2013 this behaved as expected above. No extra window is opened.

However, Excel 2016 has some modification that when A.xls is closed, an empty workbook shell remains. Afterwards, B.xls is opened in another window. So in the end I have 1 empty window and a window with B.xls.

It seems that the two windows are not independent : Closing B.xls does not create another empty Excel window, clicking close on the empty window actually will close B.xls.

Any ideas on how I should prevent the empty window when A is closed, or open B.xls in that empty window (which A left) as container and not a second window ?

在启动选项下,您可以关闭“在此应用程序启动时显示启动屏幕”,这将恢复excel / word等以恢复其以前的行为

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM