LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading an MS Word File with Tables

Solved!
Go to solution

I have experinced a snafu when executing this labview program that reads in all tables within an MS Word file and does not see some of the tables.  The original Word document has hundreds of tables in it and it would erratically skip a table in the sequence when it read in and executed the convert to text method. 

 

I whittled the thing down to a simple word file doing the same thing.  This VI does not see the second table in this word document with 2 tables.  The tables count property calculates as 2 indicating that Word sees 2 tables in the document, but when I try to convert to text the second table I get the infamous error indication from MS Word and an empty string out of the converttotext method.  

 

Anybody know how to remedy this? 

Download All
0 Kudos
Message 1 of 4
(4,208 Views)

hi id,

 

the error occours in the inner for loop.

 

 

 

for one .docx:

get rid of the inner for loop, replace the outer for loop with a while loop, stop this while loop when i +1 = count

 

 

Download All
0 Kudos
Message 2 of 4
(4,176 Views)
Solution
Accepted by topic author id

This is a tricky one. Here you are modifying the document (by using convert to text) and at the end you don't save the changes.

 

When you convert a table to text the table no longer exist and Word reassign the table indices. So in your example after table 1 is converted to text index 1 is reassign to table 2. In the second iteration you are trying to get the table with index 2 which no longer exist.

 

You can modify your code as follow to make it work: Wire the Tables -> Count value to the N terminal of the FOR loop, Wire the constant "1" to the Tables Item Index value.

 

Ben64

 

 

Message 3 of 4
(4,166 Views)

You did it again Ben thanks

0 Kudos
Message 4 of 4
(4,140 Views)