LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create report code 7 error, -41003, and file generating but not saving

Solved!
Go to solution

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. 

0 Kudos
Message 1 of 7
(1,935 Views)

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…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(1,924 Views)

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... 

0 Kudos
Message 3 of 7
(1,920 Views)

Hi Doe,

 

that's what you find when searching for "-41003" in your VI (including VIs from vi.lib):

 

That's the error source, now you can check your VI for any (in)valid path…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 7
(1,911 Views)

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.

0 Kudos
Message 5 of 7
(1,905 Views)
Solution
Accepted by topic author CatDoe

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.

  • No, the file does not exist.  So open a New Report (of type Excel) -- this is a blank Excel document with no assigned name (yet).  Add a Table, save it to Excel using the (new) name for the file, then Close the Report (which closes Excel, saving the data you just put there).

So what changes when the Excel File already exists?

  • Yes, the file already exists.  Again, open a New Report (of type Excel).  As in the first case, this is also a blank Excel document with no assigned name!  Go to the last row (which should put you on the first row, as you opened a blank Excel document), add a Table, and then close Excel.  To be honest, I don't know where Excel will save it (or even if it will save it -- no file information is provided!).

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

Message 6 of 7
(1,896 Views)

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!

0 Kudos
Message 7 of 7
(1,893 Views)