3

I'm trying to ensure that an excel file passed to my application is opened in it's own window rather than an existing Excel instance. Is there a way of telling the Process to do this? The following code always uses an existing instance if present.

Process process = new Process();
process.StartInfo.FileName = myExcelFile;
process.Start();

thanks

Matt

1 Answer 1

10

Try the following.

Process process = new Process();
Process.Start("Excel.exe", myExcelFile);

Other option is, if you use Interop (i.e. Microsoft.Office.Interop.Excel.dll ), you can do it as follows. This will always open the file in a new instance.

Excel.Application excelApp = new Excel.Application();
excelApp.Visible = true;
string workbookPath = (@"C:\Sample.xlsx");
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,
    0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
    true, false, 0, true, false, false);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.