Showing results for 
Search instead for 
Did you mean: 

Error 97 writing to spreadsheet

I have a VI which controls a CCD camera to acquire spectra and it requires the user to input a filepath with which it saves the .SPE spectrum plot. Since I need the CCD getting these spectra many times and I would like to be able to access the data in text format, I also made a VI that saves the data to a spreadsheet. This VI works, in so far as it does what it is supposed to do but every time it acquires a spectrum and saves it I get an error saying: Error 97: A null or previously deleted refnum was passed in as an input.
I suspect this might have something to do with the same file name (with different extensions) being used for both the .SPE and .txt files but that is  what I need it to do. It does exactly that as well, I have both files after clicking continue on the error message but having to click on the error message every time defeats the whole purpose of automation. So, I'm looking, ideally, for a way to fix the error or, failing that, I would also settle for a way to automatically select continue every time the error message pops up.

Has anyone had a similar problem before?


0 Kudos
Message 1 of 3

It's not clear why this is happening.  One thing you might try is to use the Error Line to "serialize" the code, starting (and completing) one File Write before starting the second.  Another thing to try is to see what happens if you just do one of the File Writes (try it with both of them -- it would be a very good "clue" if you can write only the .SPE files and can also write only the .TXT files, but get then error when trying to do both).


Bob Schor

0 Kudos
Message 2 of 3

If I had to guess it's the SPE write that's causing trouble, as nothing in the code you posted should throw any errors. Can you post the subVI you're using as well? It's likely in there.

0 Kudos
Message 3 of 3