0

when I use Interop to open an Excel file using this code

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
app.Visible = false;
Workbook wb = app.Workbooks.Open(ruta,Type.Missing  ,false);
Worksheet sh = wb.Sheets["Scenarios"];

I got the following error.

`An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred
Additional information: El servidor lanzó una excepción. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))`

But if instead putting app.Visible = false I use app.Visible=true everything works perfectly.

Why is that error? obviously what I want is open an excel file but without showing the window so the user doesn't see all the back-end process

a.ras2002
  • 385
  • 2
  • 7
  • 21
  • http://stackoverflow.com/questions/579797/open-excel-file-for-reading-with-vba-without-display – Sebastian Siemens Jun 15 '16 at 14:30
  • 2
    You can never debug RPC_E_SERVERFAULT from your end. Something very nasty happened inside Excel, you don't know what. Maybe there's a breadcrumb in the Windows Application log. That the Visible property appears to have an affect is pretty unusual, that almost surely has something to do with the specific spreadsheet you are trying to load. A misbehaving macro, perhaps. – Hans Passant Jun 15 '16 at 15:01
  • Ok, thanks I will try to "clean" the Excel as much as possible, and see if that way it works. I will keep you informed just for your information, and in case others will have the same problem as me in the future – a.ras2002 Jun 16 '16 at 09:53

0 Answers0