08-01-2023 09:33 AM
There is a well-known issue with the Report Generation Toolkit regarding the Excel Save function crashing LabVIEW when ran in an executable. This happens when the dev machine uses a different version of Office than the deployment machine.
The issue is, at its core, the Workbook.SaveAs method, which is called in "Save Report to File.vi" in the RGT (but this happens just using the regular ActiveX calls, so this happens even if you're doing it manually). Apparently, Microsoft changes the underlying functions every so often, which can result in a crash. One fix was to simply relink the SaveAs invoke node, but that doesn't always work. A few reference links:
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PAmLSAW&l=en-US (this refers to the WorkIdentity parameter, which should be resolved by just installing all of the updates and relinking the Invoke node)
https://forums.ni.com/t5/LabVIEW/Save-Report-to-Fil-vi-crashes-when-built-as-executable/td-p/3911396 (possibly related)
https://forums.ni.com/t5/LabVIEW/Excel-Save-Workbook-error/td-p/3577611 (relinking method explained)
I ran into this issue recently. My dev machine uses Office 365, and I was trying to troubleshoot a remote client machine running Excel 2016. Both machines were up to date, and both had the WorkIdentity parameter in the SaveAs method, but the LabVIEW executable just silently crashed and closed when SaveAs was called.
The recommended fix is to require the use of the same version of Office on the development machine as the target machine. (Rolfk explained this well but I can't find that post this morning, my apologies).
Unfortunately, my client's machine was several states away, and changing Office versions wasn't an option. The workaround that I found was related to this Stack Overflow post. It's not ideal, but you can use SaveCopyAs (at least in my case) in both versions. Basically, open your template and edit it, then run SaveCopyAs with the final filename. That's it. At least today, at the time of this writing, it will let you run code developed in Office 365 on a machine with Office 2016 installed on it.
(Note, I didn't try the Worksheet.Save method, just the SaveAs method. Save might or might not work; YMMV.)
Solved! Go to Solution.
08-01-2023 09:34 AM
Postiing to mark solved: if you can't change Office versions, try using SaveCopyAs instead of SaveAs.