-1

System.Diagnostics.Process.Start() not launching an excel file In Excel 2013 and that too launched from inside excel comaddin.

string filename = @"C:\Users\centraluser\AppData\Roaming\STUDIO\CENTRAL\d7c98719-7aa9-4e7e-8fb6- 
   bd5a5b23f560\New Microsoft Excel Worksheet.xlsx";
ProcessStartInfo processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = filename;
var process = Process.Start(processStartInfo);

It hangs after Process.start and waits for some time and then returns with a null process value.

While the same file gets launched if I use the same code and try to open the file from a console application.

And all this behavior is only occurring with Excel 2013 only.

Kindly help on the same.

  • Any hElp on this please? – Arun Goyal Feb 12 '20 at 06:09
  • A new Progress i have made in this. If I try to open the excel in this way - string filename = @"C:\Users\centraluser\AppData\Roaming\STUDIO\CENTRAL\d7c98719-7aa9-4e7e-8fb6- bd5a5b23f560\New Microsoft Excel Worksheet.xlsx"; Process.start("Excel.exe",filename); then the excel file is opened.Can anything be inferred from this?? – Arun Goyal Feb 12 '20 at 07:41

1 Answers1

0

From MSDN:

Set the UseShellExecute property to specify whether to start the process by using the operating system shell.

Set the processStartInfo.UseShellExecute to true value.

EylM
  • 5,967
  • 2
  • 16
  • 28
  • Useshellexecute was bydefault true.And problem arises onlyy when launched from inside Excel com addin code and Excel 2013 is used – Arun Goyal Feb 11 '20 at 16:24