LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read an opened Excel

Solved!
Go to solution
I have a 3rd party application that exports real-time data into an onscreen excel file. We would like to access to the data and synchronize with other data from our Labview applications. I tried several Labview/ActiveX examples, but was unsuccessfull. First. we tested using Excel Macro to save and Labview to read dynamically. The onscreen, but not the saved, excel file remained to be updated. This made the LabView read the same numbers continuously. We also tried using LabView to save and read directly. However, when the 3rd party application was exporting, the LabView stopped with error. Apparently, there was a conflict due to this continous access to a same file by two different applications. I would appreciate any comments or suggestions.
0 Kudos
Message 1 of 11
(4,867 Views)
You can't have an Excel workbook opened by two different applications at the same time. One application has to close the file to give the other one access to it.
0 Kudos
Message 2 of 11
(4,847 Views)
Thanks. Can the active Excel file be copied and then read by LabView?
0 Kudos
Message 3 of 11
(4,806 Views)

Of course. There is a Copy File function. This assumes, of course, that this other application is saving the file as it's writing.

 

One thing that I wanted to clarify in my statement is that you can't have two applications trying to write to the same Excel workbook at the same time. You can, however, have one application writing to Excel and have LabVIEW read that data. As long as the LabVIEW program doesn't close the workbook or quit Excel that should work. For instance, I can have a workbook open with Excel and keep Excel opened, and have LabVIEW read the contents of the workbook. As I make changes to the workbook I can run the LabVIEW code and see the changes. 

0 Kudos
Message 4 of 11
(4,800 Views)

I can open an excel workbook then open the same workbook with active-x calls from LabVIEW. 

I trigger on user events to read a worksheet.  Any changes made in excel are visible in LabVIEW.

I must close the workbook from LabVIEW before quitting excel otherwise excel has a hissy fit and I 

have to logout of windows and login again.

 

 

Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 5 of 11
(4,787 Views)
Thank you all. It is what we try to do to continuously have one application writing to Excel and LabVIEW read that data. I would appreciate any examples related to this setting. The comments on the user-events made by Dave is also interesting. If "Any changes made in excel are visible in LabVIEW", it should help solve our problems. Could you provide some details? I am a biomedical scientist with limited experience in LabView. Thanks a lot.
0 Kudos
Message 6 of 11
(4,772 Views)
I'm not sure what you mean by "settings". There are no settings in Excel or LabVIEW. The attached VI (LV 8.2) is a simple modification of a standard "Read Excel Workbook" VI that I have that simply accesses an already open workbook and reads the contents of the sheet.
0 Kudos
Message 7 of 11
(4,759 Views)
Solution
Accepted by topic author yfc500
If you want to track the change actively you will need to register a callback for an ActiveX event. For example, you can use the Sheet's "Change" event. See attached example, which uses a dummy control to trigger the event structure. You could also use a user event - doesn't matter much in this case.
0 Kudos
Message 8 of 11
(4,755 Views)
Excel Track Sheet Change VI works. Thanks.
0 Kudos
Message 9 of 11
(4,743 Views)

Sorry to bring up an 9 year old post.

 

This track sheet change is really great but I have a spreadsheet that's constantly being updated with a new row being added every second. Is it possible to bring data from this new line into labview?

0 Kudos
Message 10 of 11
(3,124 Views)