LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to loop a vi

Hi,

 

I have been searching the threads for a way to open and extract data from an excel file and display it on screen. I managed to find an example which pretty much does what i need it to do.

I have attached a copy of this so that anyone reading this can have a better understanding of my questions.

 

An over view of what i want to do and why is as follows.

 

I have a system which is currently performing DDEpoke of data into an excel spreadsheet after the VI first opens this excel file. the original VI would open the spreadsheet and then read the data being supplied into the excel file. It would then display the numerical values in individual slide display bars and then output those values as analogue voltages to be measured externally to the computer.

 

When we moved the software onto a new windows 7 64 bit pc there is an error which I cant fix and the person who origanlly wrote it is no longer working for our company. They also took the origanl files with them so no chance of updating it.

 

I am now working to write a new one to perform the same job.

 

The example vi i have attached uses ActiveX and allows me to open the excel file, extract the data I want and does display this in an array. BUT, it then closes the file and finishes the sequence.

 

What I would like to do is change it so that it opens the excel file, retrieves the data, displays it and then waits for any changes and then updates the display.

I only want the sequence to close when the operator chooses to do so.

 

Can anybody help me with how to loop the data extraction and update the display?

 

thanks in advance

 

Nathan

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

Hi Nathan,

It sounds like you might just need a while loop with a few shift registers, but I don't know for sure because the three vi's in your included library all only open things from excel. I don't see any file closing in your vi's here.

 

Could you upload the main vi you're working with which you want to loop? I'm referring to:

 

"The example vi i have attached uses ActiveX and allows me to open the excel file, extract the data I want and does display this in an array. BUT, it then closes the file and finishes the sequence."

0 Kudos
Message 2 of 4
(2,192 Views)

Hi,

 

Sorry I think i uploaded the wrong file. This one should have the main vi that i have been working with.

I have changed a few simple things in this to do some of the jobs I want it to do but just cant seem to stop the sequence from ending. I have tried a whiloe loop around various sections of the sequence and have removed the close functions towards the end but this hasnt helped at all.

 

nathan

0 Kudos
Message 3 of 4
(2,144 Views)

Your code uses ActiveX calls, which I believe Microsoft has largely abandoned.  Certainly it is much more difficult to access the Help Files in Windows 7 than it was in the dearly-departed Windows XP...  However, all is not lost -- LabVIEW provides a much better and easier way to access Excel through the Report Generation Toolkit.  

 

There are elements of your original problem that I do not understand, but it sounds to me like you should be able to do the following:

 

Use New Report (with the name of the existing Excel Workbook as the "template", which means "input", file).  Read the data that you need from the Spreadsheet you specify using the Excel Get Data function.  It wasn't clear what looping you needed to do, whether you were reading multiple entries or adding multiple entries to Excel (you can also write to the Spreadsheet).  When you are done and have exited the loop, you Save Report to File and then Dispose Report.  Note that there is a feature/bug (reported to NI) that causes the Excel Workbook to be deleted if the user manually closes Excel before LabVIEW does its Save/Dispose sequence, not what you want to happen!

 

It seems to me that the Excel part should be pretty easy with the Report Generation Toolkiit functions.  Can you put together the rest of what you want to do, perhaps with dummy VI's that say "Read something from Excel Here"?  If we have a better idea of what you want to do where, we might be able to offer further suggestions.

 

Bob Schor

0 Kudos
Message 4 of 4
(2,099 Views)