LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Tables in MS WORD using LabView & ActiveX

I would like to be able to read tables contained in an MS WORD document using LabView and ActiveX. (I've been successful in doing this with Excel files.  ( I am not using the report generation toolkit.)  After searching numerous posts with similar questions about LV & ActiveX  I've not found any solution to my specific app.  In LabView I'm successful doing an "Automation Open", followed by a Property Node, to an Invoke Node ("Documents" Open) and then a Property Node with "TABLES" selected. That's where I get stuck. Now that I have a reference (?) to "Tables" I can't seem to figure out what I need to connect and follow that with in order to now read the Tables in my document.  I guess that's due to my lack of understanding as to what exactly this "Table" property node output actually is.  Can someone tell me what this reference output is referring to and how I can get to the Tables within the document from it?  I've tried connecting both a property node and invoke node to no avail.  Can someone point me in the right direction?
 
Thanks. Ed
0 Kudos
Message 1 of 4
(7,800 Views)
Hi Ed,
the attached picture shows how you can read the content of the selected table.

Hope it helps.

Mike

Message Edited by MikeS81 on 05-25-2008 01:04 PM
Message 2 of 4
(7,773 Views)
Thanks Mike. I'll try this out. Looks like that's what I'm looking for. This should also be a good springboard for me to to access other objects within a WORD document from LabView.  I've often said that someone should author a nice tutorial for the LabView programmer who is interested in accessing WORD and EXCEL documents programmatically using ActiveX directly.  (hint hint...) Thanks for the heads up. Much appreciated. Ed
0 Kudos
Message 3 of 4
(7,739 Views)
Dear Ed,

Figuring out "what I need to connect and follow that with" relates to the organization of the MS Word Object Model.  Please refer to the Word Object Model Reference MSDN >> MSDN Library >> Office Development >> 2007 Microsoft Office System >> Word 2007 >> Word 2007 Developer Reference >> Word Object Model Reference.  You can think of the Object Model as a software hierarchy.  You must start at the top of the hierarchy and work your way down to the item of interest.  You must descend the hierarchy one level at a time; you cannot skip levels.

At each level of the hierarchy, you have access to the methods and properties of that "level". Click on the Tables Collection link from the Word Object Model Reference page.  Notice how Tables is at the top of the hierarchy.  When you have a LabVIEW reference to a Tables object (technically speaking a collection), you then have access to the methods and properties supported by this "level".  Click on the Tables Object Members link.  Here you will see that the Tables collection supports two methods, Add and Item, and also supports five properties, Application, Count, Creator, NestingLevel, and Parent.

Notice how Mike gets the Count property of the Tables object.  He then uses the Item method to return a reference to an individual table.  The key thing to take away from this is how Mike uses the Item output node to gain access to the methods and properties of the Table object (not the Tables collection).  Mike has descended the hierarchy from Tables to Table.  He descends the hierarchy again with the Cell method and Range property of the Table and Cell object respectively.  Lastly, the Text property of the Range object, "Returns or sets the text in the specified range or selection."

Effective LabVIEW programming with this type of ActiveX control requires a fair understanding of how Microsoft organized its software libraries.  The Object Model Reference is a good place to start visualizing how these libraries are organized.  Thank you for using the forums Ed, and thanks for your post, Mike.
Message 4 of 4
(7,720 Views)