We have a C# application that executes a fairly complex Excel macro for reporting purposes. The macro runs fine for smaller datasets, however, when the data it needs to process becomes large, we get a:
System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)) at Microsoft.Office.Interop.Excel.Workbooks.get__Default(Object Index)
after about 7 minutes of processing.
This is the syntax we use to execute the macro:
excelApplication.Run(macroCommand, DataBook, DataSheet, macroParameter);
...where excelApplication
is an instance of Microsoft.Office.Interop.Excel
, macroCommand
is a string name of the macro, DataBook
is the Excel workbook, DataSheet
the worksheet to use and macroParameter
is just a placeholder parameter.
I have read about implementing DoEvents()
, but unsure how and if this will rectify the current issue?
Any help would be greately appreciated.
I ended up using DoEvents() within the Macro itself, adding it at the start and end of each loop.
User contributions licensed under CC BY-SA 3.0