Jump to content

New Excel Process


UEZ
 Share

Recommended Posts

Since Office 2013 Excel uses the same instance to open Excel sheets.

E.g. if your app starts Excel using COM (Excel.au3) and you open another Excel sheet from windows explorer than this sheet will be attached to your instance.

When you close your app it will automatically close also the other attached sheet.

Is it possible to implement in AutoIt something like this here?

Source: https://social.msdn.microsoft.com/Forums/office/en-US/25794163-d33b-478b-af6a-7dd0bf437380/how-to-make-sure-that-opening-a-workbook-starts-a-new-excel-process-and-does-not-use-the-existing?forum=exceldev

Process excelProcess = new Process();
            string filePath = @"C:\Users\Person\Desktop\OPen.xlsx";
            excelProcess.StartInfo.FileName = @"C:\Program Files\Microsoft Office 15\root\office15\EXCEL.EXE";
            excelProcess.StartInfo.Arguments = @"/x " +filePath;
            excelProcess.Start();
           Thread.Sleep(10000);
           

            Excel.Workbook workbook = Marshal.BindToMoniker(filePath) as Excel.Workbook;

            Excel.Application excelApp = workbook.Application;

            Console.WriteLine(excelApp.ActiveWorkbook.Name);
            excelApp.Quit();

 

I'm using

_Excel_Open(False, False, True, True, True)

but it doesn't work.

 

Thanks.

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • Moderators

Hi, @UEZ. This opens in a separate process for me, or am I misunderstanding what you're after?

#include <Excel.au3>

$oExcel1 = _Excel_Open()
$oExcel2 = _Excel_Open()

$oWorkbook1 = _Excel_BookNew($oExcel1)
$oWorkbook2 = _Excel_BookNew($oExcel2)

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I'm developing an app using Excel COM to display a rack layout according to the Excel sheet data.

My problem is that when I open Excel in my app using

_Excel_Open(False, False, True, True, True)

it opens Excel hidden in the background as a new instance. So far so good but if I'm opening another Excel sheet using windows explorer this newly opened Excel sheet will be attached to the Excel.exe process which I've opened within my app.

When I close my app it will also close the external opened Excel sheet. Ideally would somehow to open Excel COM within a script using the /x parameter and attach the Excel COM to this opened Excel process.

This is what the code above is doing.

 

Imho the instance handling with Excel 2013 is regarding this issue not good solved.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...