LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error -2147417848 when writing Excel reports

Solved!
Go to solution

Hello,

 

I am trying to create reports in Excel using data collected from my application. When I run the main VI from the project environment I get no errors. However, after building the application and running the EXE I get the error below:

 

SnakeFish_0-1691002948929.png

 

This occurs after I open the template file, save as new file, then open the new file to copy the sheet. I cannot tell why this only occurs when I run the EXE. I've attached the relevant VIs. I've ruled out the file type and anti-virus.

 

Any advice is appreciated.

0 Kudos
Message 1 of 5
(990 Views)

Thank you for attaching your code.  Most seasoned LabVIEW developers will have LabVIEW 2019 or 2021 installed, and relatively fewer of them have LabVIEW 2023.  To all those (such as I) to open your VI, please "Save for Previous Version" and specify LabVIEW 2019 or 2021.

 

Bob Schor

0 Kudos
Message 2 of 5
(968 Views)

Hi Bob, 

 

Thanks for the help, I've changed them to LabVIEW 2019. I ran Copy_Sheet on its own and the same error was now produced.

Download All
0 Kudos
Message 3 of 5
(939 Views)
Solution
Accepted by topic author SnakeFish

Thanks.  I think I see what you are doing, though you are getting "more in the weeds" than I typically do with Excel Workbooks (usually I try to stick to Worksheets whose structure I know, or can easily deduce, and can then use the RGT tools, including Excel Easy Table, to build my Worksheets and Workbooks.

 

One thing I've found that doesn't seem to be documented is what to do after you write to Excel and want to Dispose Report.  The answer is "you wait" (I typically wait 200 ms).  And if you want to open another Excel Report, you might want to do another Wait (I'd probably advise 500 ms).  I don't think this is a LabVIEW problem, but rather Micro$oft not playing so well with other parties.

 

See if that helps.

 

Can you pinpoint where in your code things go awry?

 

Bob Schor

Message 4 of 5
(917 Views)

Sorry for the wait, back stateside.

 

I think you have the solution for me. The part were the error hits in the Write Excel VI is after the Copy Sheet VI call. I placed a flat sequence to force a wait in-between the Dispose Report Ref and Copy Sheet VI calls and so far the error is gone. For whatever, reason the EXE must be running just fast enough to trigger the error by reopening the newly renamed file before the reference is closed.

 

With this 1 second wait, I no longer have the error. I will run more tests. Thanks so much for the suggestion Bob.

 

-SnakeFish

0 Kudos
Message 5 of 5
(878 Views)