Following Exception is thrown if I try to open an excel file on a client machine:
Exception from HRESULT: 0x800A03EC
Inner Exceptions: (emp
We have converted our Client / Server solution from 4GL language to C#, where embedded C# code below worked without any issue before, and started to receive same error message.
Excel.Application excelApp = new Excel.Application();
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(fileExcel,
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
I have followed all the instructions in this thread, but to no avail, until I have realised that in our case at least fileExcel, which contains the full path with the name of the file and defined as System.String fileExcel had trailing spaces, e.g. instead of "C:\temp\MyTest.xls" it was "C:\temp\MyTest.xls[many many spaces]".
Once I have added Trim() to fileExcel as below, all went back to normal. Hope it will help to someone in the future.
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(fileExcel.Trim(),
0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);