LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi does not stop when xls file is open!!!

Hi to all!!!!!!!

                     My vi includes xls file open and store the data until vi stops....but the problem is when that excel file is open which is updated by running vi and when I try to stop the vi it gives error ...so how to solve this error......is it pssible to stop vi without error or is there any possibilty so that when vi is stop it stops that excel file which is opened......I am attaching the vi part.... 

0 Kudos
Message 1 of 4
(2,714 Views)

First, you are not creating an Excel file.  You are creating a text file that you just happened to give an extension of .xls.  You really should give it a .txt extension so you don't confuse it with a real Excel .xls file.

 

Second, what kind of error are you getting?  Are you saying you have a file already open in Excel when you start your program?  Of course that will give an error because you can't have two programs (Excel and LabVIEW) open the same file at the same time.  One will lock out the other.  You do have an error (put an error indicator or probe on the wire inside the loop).  You just don't happen to see th error right now because the error is being passed to the tunnel of the loop.  Only when you stop the loop and that error passes to the close function, then nowhere else, does the automatic error handling pop up a dialog box saying you have an error.

 

Your solution (besides using multiple periods unnecessarily to separate your sentences) is to not try to open a file that is already open in Excel.  You can wrap your other code in a case structure so that it only executes if there is no error coming out of the Open File function.

Message 2 of 4
(2,707 Views)
ya !! you are right (I know) , I am opening text file with xls extension....but I don't know is something wrong in doing that??? (tell me if there)......please  you just run the vi which is posted.....error box suggests that File already open....so I want to know that if I press stop button then can I check that if file is open then close first and then stop the vi??? Or is it possible to stop the vi even if the file is open.....
0 Kudos
Message 3 of 4
(2,701 Views)

MSD100 wrote:
ya !! you are right (I know) , I am opening text file with xls extension.  But I don't know is something wrong in doing that??? (tell me if there).  Yes.  It leads to confusion.  An .xls extension tells people you are using an Excel spreadsheet file, when in reality you are not, it is a text file.  Please  you just run the vi which is posted, error box suggests that File already open.  So I want to know that if I press stop button then can I check that if file is open then close first and then stop the vi??? Or is it possible to stop the vi even if the file is open.

Yes, the VI will stop if you just hit the "Stop" button that comes up on the error dialog.

 

As I said, you should do something like this.

 

Now, if you have an error when it opens, it won't run the other code, it will pop up a dialog, then end.  You can restart once you close your file in Excel.

 

I put a wait statement in the loop so that the program doesn't run ridiculously fast and create a huge text file.

 

 

Message Edited by Ravens Fan on 05-21-2010 10:08 AM
Message 4 of 4
(2,676 Views)