How to fix a "System call failed" exception when using Office Interop Excel and macros

0

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.

c#
excel
vba
asked on Stack Overflow Feb 12, 2017 by Rudolf Lamprecht • edited Jul 9, 2018 by Community

1 Answer

0

I ended up using DoEvents() within the Macro itself, adding it at the start and end of each loop.

answered on Stack Overflow Feb 15, 2017 by Rudolf Lamprecht

User contributions licensed under CC BY-SA 3.0