I\'m opening an xlsx file and saving each sheet into a csv file.
Here is the relevant code for the saving:
int i=0;
foreach (Excel.Worksheet s in app
In my case, the exception was been thrown because my excel Interop tools was displaying a modal dialog (associated with a expired licence key - shame on me). If I closed the dialog (which was been displayed in the background) and then hit 'continue' in Visual Studio, the program was able to connect to the xlsx file and retrive data succesfully.
In my case there was a same exception and checked task manager, there was a lot EXCEL.exe, Kill them and then worked fine
I think this is a binding issue, I just surrounded every call (SaveAs, Select) with a:
bool failed = false;
do
{
try
{
// Call goes here
failed = false;
}
catch (System.Runtime.InteropServices.COMException e)
{
failed = true;
}
System.Threading.Thread.Sleep(10);
} while (failed);