09-15-2022 11:56 AM - edited 09-15-2022 12:02 PM
I am trying to generate and save a file, but receiving errors that very day to day. Some days the VI works fine, other days I keep getting code 7 and other errors. Nothing in the VI has changed from day to day. It should be simple, but I am not sure why this VI was the issue when the other VI is an exact duplicate with different data and operated fine.
Attached is the VI as it currently stands after I have spent time trying to troubleshoot it and failed. I would like to do the following:
Check if file exists.
true:
open existing file at specified path
append rows to the end of the file
close file
save file to specified path
opening and closing file must be done in minimized state
false:
create a new file at file path location
add rows of data
close file
save file to specified path
opening and closing file must be done in minimized state
I need to trash the report at the end to free up memory. I am doing this with two batches of data within the same folder path, similar names differentiated by "_stats" in the name.
Sometimes the file opens, generates data, closes and does not save in the folder despite the probes verifying the code and no error codes were shown at the end.
Solved! Go to Solution.
09-15-2022 12:05 PM - edited 09-15-2022 12:08 PM
Hi Doe,
@CatDoe wrote:
I am trying to generate and save a file, but receiving errors that very day to day. Some days the VI works fine, other days I keep getting code 7 and other errors. Nothing in the VI has changed from day to day.
So maybe something outside your VI has changed "from day to day"!?
As you are accessing Excel files using RGT functions: is Excel in some cases open and is Excel accessing some of those files?
When Excel opens a file it will block any concurrent file access - your VI might run into errors…
09-15-2022 12:10 PM
Hello GerdW,
As far as I am aware excel is not running at all (even in the background) during the individual VI execution. This may be why the second excel VI in my program has issues -- I need to check the timing between closing the first file and opening the second.
However, while running the VI by itself excel is closed completely and not running in the background. I still get random errors, even the -41003 despite the other VI using the exact same file path successfully with "_stats" added to the name...
09-15-2022 12:27 PM
09-15-2022 12:32 PM
I did check my file paths and have confirmed they do exist and LabVIEW can access them based on the other VI. I'm not convinced this is the reason for the -41003 error...
These two VI's are exact duplicates of each other with different data and one additional string constant in the name.
09-15-2022 12:46 PM
This is, indeed, a subtle problem that I think I can explain. Start with the name of the Toolkit -- the Report Generation Toolkit. It is designed to generate (as in "write-only") one of three types of Reports -- a Word Document, an Excel WorkBook, or an HTML file.
Consider your program. You ask "Does this Excel File already exist?". We'll do the easy case first.
So what changes when the Excel File already exists?
The "mistake" is thinking that the RGT is an extension of the LabVIEW File I/O functions -- it is not, it is a Report Generation Toolkit, designed to be a "write-only" set of tools. But do not despair -- NI comes to the Rescue.
Examine the Create Report function. There is another input called "Template". This refers to an existing Excel Workbook that can be opened and can be treated as something you can read from and write to. You will, of course, need to also Save the data to Excel if you want it to persist when you Close the Report ...
Try that, and see if that makes a difference.
Bob Schor
09-15-2022 12:52 PM
Hello Bob,
That may be the issue. Now that I think of it, all this chaos did begin happening when I removed the template from the VI to simplify the number of files outside of LabVIEW. I guess I need to add them back in as mandatory files.
Thank you!