Error -41106 When using LabVIEW to Generate Excel Reports Continuously

Updated Aug 30, 2023

Reported In

Software

  • LabVIEW
  • LabVIEW Report Generation Toolkit

Other

Microsoft Excel

Issue Details

I created an application in LabVIEW that needs to generate a graph report in Excel, save the report and close it.
This process needs to run 20 times continuously.
But when I run the program it makes Excel crash after only few reports were made, and displays this message:


Error -41106 occurred at NI_Excel.lvclass:new
report subVI vi -> NI_Report.lvclass:Create
Report vi -> Modular Excel Report Generation vi
-> Report(constant - Multiple) vi -> NI Test
VI vi


How do I solve it?

Solution

This Excel crash appears due to LabVIEW and Excel running unsynchronized since they are both undeterministic programs and at some point it appears that an Excel report does not get enough time to close before a new report is open, causing LabVIEW to crash and report this error.

By providing some time delay in the Dispose Report VI

Enter the Dispose Report VI choose to open NI_Excel.lv.class:Dispose Report.vi and set the Wait (ms) Function inside to approximately 300 ms, see picture below.

Additional Information

This kind of errors with Report Generation Toolkit can sometimes appear and usually are system dependent.
This solution does not Guarantee this error will not appear to generating an infinite number of reports and the time delay you may set is system dependent.