From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read tables from word file

My recommendation would be to first concentrate on getting the data input portion of the code working the way the users want it to. During this phase, just save the data to a tab-delimited text file. This format is easy to generate, easy to read and (if you implement it in the form of one VI that reads a dataset and another that writes datasets) easy to upgrade to something better later.

Once the data entry portion is working the way users want, create the print routine. All you have to do is create a VI with a white front panel and place on it indicators to display the data you want printed. You then use the VI server functionality to tell the VI to print itself. The only thing to remember is that you have to have at least one property node on the diagram of the "print" VI. This causes LV to update the VI's front panel even if it's not open. Normally LV doesn't update a subVIs front panel unless it's open, however the presence of a property node overrides this behavior. Again, I can send you an example of this type of operation...

When the printing is working the way you want, you can come back to the data management piece and replace your two IO routines with versions that fetch the information from a database or whatever you want.

Now, the reader version of the program would be the same as the regular version but without the screen that allows the user to modify/enter data. Again, if you structure the code right, generating the "data reader" version of your application is simply a matter of reconfiguring your standard code base to use one display screen rather than another one--or possibly setting an input that in the reader version of the software, disables all the data input fields and turns them (essentially) into indicators.

There are a bunch of ways of doing this sort of thing. I have also developed systems that used software plugins to vary the application's functionality.

Hopefully this hasn't confused you. We can as you like, cover each piece in more detail.

Mike...
mporter@arielcorp.com

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 11 of 16
(1,489 Views)
Hi all,

I think, a good solution to this problem could be using a Copy.vi from advanced File I/O menue. I tried it with Excel file. First, you copy (save) your .xls file as .prn file (or .doc to .txt) and then, you can read it with Labview without using ActiveX. You can also write or update the same .xls (or .doc) file, because you still have a copy of it, and again without using ActiveX.

Igor
0 Kudos
Message 12 of 16
(1,489 Views)
Unfortunately it didn't work as I expected, but the idea was: save a .doc or .xls file as a .txt or .prn respectively and then read it. Of course, you can do it manually. Any criticism is welcome.
0 Kudos
Message 13 of 16
(1,489 Views)
Hi,

Thanks for your feedback on the MS Office toolkit!

We had not thought of your use case, and therefore did not enclude VIs that allow you to read data from a table in Word. I talked with the toolkit developer, and he said that he could write a few quick VIs that would help you read data from a Word table. Basically, you just need to call the proper properties and methods that Word exposes to achieve this "custom" functionality. If you need any additional functionality in the future just refer to the Object Model for that product (i.e. Word, Excel, etc.), and use the existing VIs as templates.

Enclosed are 4 VIs. The first VI (Word Count Table) returns the number of tables in the Word document. The next two VIs (Word Read Table (with and without
empty cells) read the data in the Word table into a LabVIEW table (2D array of strings). These two VIs use different methods for reading the data from Word. The VI called Word Read Table is a more streamlined algorithm, and should be the default VI that you use to read the table. However, if the table has any empty cells, then you should use the VI called Word Read Table (empty cell). The final VI shows how to use the VIs to call an existing Word document. Basically, on the New Report VI, you wire the path to the Word Document into the Template terminal.

I tested these VIs with LV 6.0.2 and version 1.0 of the Office toolkit, so you shouldn't have any problems running them.

Thanks again for your feedback, and have a great day!
Joel Andersen
LabVIEW Product Support Engineer
0 Kudos
Message 14 of 16
(1,489 Views)

How do you make this code work in 8.6??  I opened the example in 8.5.1 and it worked great.  I then tried to open it in 8.6 and it was broken. Could you possibly post and example with the newest report generation toolkit?

 

Thanks

BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 15 of 16
(1,205 Views)

here is the solution that I came up with in LV 8.6. 

 

PS.  Something like this would be a good addition to the report generation toolkit.

 

 

 

BJD1613

Lead Test Tools Development Engineer

Philips Respironics

Certified LV Architect / Instructor
0 Kudos
Message 16 of 16
(1,189 Views)