Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello,

I use a WebBrowser control to open an Excel file.

The problem is that if there is already an open Excel before, the WebBrowser uses the same instance of Excel (Application).

Is there a method to indicate that the WebBrowser should create a new instance of Excel?

Or is it possible to force (or prevent) new Excel files to open in a specific instance?

thank you
Posted

1 solution

If i understand you well...

MS Excel is a single-instance application, which means that Excel will open next file in the same instance. To force creating another instance, using Interop, you need to open it using new keyword.
C#
Excel.Application oExcFirstInstance = new Excel.Application();
Excel.Application oExcSecondInstance = new Excel.Application();

oExcFirstInstance.Workbooks.Open(...);
oExcFirstInstance.Workbooks.Open(...);
oExcFirstInstance.Workbooks.Open(...);

oExcSecondInstance.Workbooks.Open(...);
oExcSecondInstance.Workbooks.Open(...);
oExcSecondInstance.Workbooks.Open(...);
 
Share this answer
 
Comments
Member 9565931 17-Apr-13 3:29am    
I know that.
The problem is that I use WebBrowser, and I can not use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900