04-02-2009 09:15 AM
I attached a sample that illustrates what I’m trying to accomplish.
I am using LabVIEW 8.6 with the latest RGTK
Mike
Solved! Go to Solution.
04-02-2009 10:46 PM
How are you running this VI? Is it a subVI in a loop in another VI?
I think the problem is that if your try running it again, you get the error because the file is already open, just like the error says.
You open up a report reference at the beginning of this VI, but you don't close it out at the end using the Dispose Report subVI. So when you run it again, you are trying to reopen a file that is already open.
04-03-2009 08:27 AM
Ravens Fan wrote:How are you running this VI? Is it a subVI in a loop in another VI?
The attached vi is just an example.
I’m trying to log data to a spreadsheet that the end user keeps open to monitor while data is logging. I would like to save the spreadsheet after each line of data is written, which is every few minutes in order to prevent accidental data loss. In the previous version of RGTK saving the spreadsheet more than once while it was still open was not a problem. This issue showed up when my customer upgraded to LabVIEW 8.6 and new version of the toolkit that uses classes.
Anyway, I was able to put in a band-aid fix by modifying the Excel save vi in the toolkit to ignore error 5. It’s not the best solution, but it will work until a better one comes along.
04-03-2009 04:08 PM
Hello M Kepple,
This error is derived from the Open/Create/Replace.vi that is located in the Save to Report file. This VI cannot open or replace a file if it is already open. In your program you don't close the file. If you are only writing to a file about once a minute I would recommend closing and opening it each time.
Note: If you are writing to this file very frequently do not do this. I am still looking for a better work around for you as well.
04-04-2009 09:22 PM - edited 04-04-2009 09:27 PM
Mike,
I agree with you that the behavior is incorrect. Even with a dispose report at the end, the error is still reproducible. The user should not have to put a close file reference in code when using RGT. After playing with the VI, it seems that the mechanism implemented to prompt the user to overwrite an existing file if the 'Prompt to Replace' function on the save is a 'True' is causing problem.
I modified my VI to the following, and it works fine (I tested in a for loop to save 100 times in a row with no problems ) The only issue is now the prompt to replace function is nonfunctional. If you need this, let me know and I can throw a quick workaround in to allow for that.
I will be filing a Report to R&D that the operation is not working as intended, if I hear anything back, I will surely let you know, but for now this should make everything work out for you, without having to ignore error codes(bad!)
07-16-2009 02:05 PM
07-17-2009 03:41 PM
Hello Dan,
I don't have the exact code that Rob created but it appears to me that all he did was remove the case structure and the File I/O functions. If you look in the subVI that is on this diagram it simply uses the SaveAs ActiveX method to save the notebook, so each time you call this VI you are simply calling the ActiveX method and saving the VI, even if it is open.