LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview continuously writing data to excel file and emailing periodically

Hi

   I am trying to write the measured value continuously to excel file using Write to measurement file (save to one file) and emailing it periodically.For first time execution (1st period) ,the excel file is mailed successfully.For second time its shows error as 

LabVIEW: (Hex 0x5) File already open.

C:\Users\viki\Documents\LabVIEW Data\test.xlsx

The written file is open in mail attachment.How to over come this. I am attaching vi.

                                                      Thanks in advance

With regards 

Vignesh M

0 Kudos
Message 1 of 5
(2,738 Views)

From your description of the error and an examination of the VI you attached (thank you!), the problem, I think, can be found in "Untitled 1(sub-VI).vi", the sub-VI that you use to e-mail the Excel file.  This sub-VI, however, wasn't attached, so I cannot tell where the Excel file was opened, and (more importantly) when, or if, it was closed.  The fact that you got an error saying the file was still open suggests that ... the file was still open!

 

Bob Schor

 

P.S. -- you should learn to store LabVIEW "variables" in Shift Registers and to not use Local Variables in your code.

0 Kudos
Message 2 of 5
(2,727 Views)

Thanks for your response. Iam attaching sub vi here....measurement file vi shows file open..I think attachment file path for mail causing error?...

0 Kudos
Message 3 of 5
(2,720 Views)

@vikiece93 wrote:

Thanks for your response. Iam attaching sub vi here....measurement file vi shows file open..I think attachment file path for mail causing error?...


I think you are correct.  I also note that you have not used Error In/Error Out and have not "serialized" this sub-VI.  You should also know that you are calling .NET routines that exist entirely outside the realm of LabVIEW, so you need to do something to ensure that the Excel file is capable of being re-opened and re-written after the Mail and its attachment have been sent.

 

You may want to rethink this process.  Note that your main loop seems to be appending to a single Excel file.  So consider that you run 10 loops -- you write 10% of the file, e-mail it, write the next 10% (to get a file 20% of the final length), e-mail it (it takes twice as long, and you get the first 10% in both e-mails), write the next 10%, e-mail, etc.  Each loop the file grows in length, takes more time to e-mail, your program slows down, and instead of getting one e-mail with one copy of the file, you have 10 e-mails, all with the first 10%, 9 with the first 20%, and 1 (the last one) with the entire file.  Does that make sense?  Is that what you want to do?  Does that sound like a Good Design?

 

Bob Schor

0 Kudos
Message 4 of 5
(2,707 Views)

Thanks for your suggestion.I changed my idea about sending data through mail.On any special event data will send as text message through mail.

0 Kudos
Message 5 of 5
(2,701 Views)