Reading values from a table in Word...

S

Stu

Hi,

I am trying to extract the values from a few specific fields in a word
document from VB.Net.

I have opened the doc and can loop through all the paragraphs...but the
table data is not returned.

Is there any way of getting the value from, say, the 3rd table, 2nd row, 1st
column.

Thanks in advance,

Stu
 
C

Cindy M -WordMVP-

Hi Stu,
I am trying to extract the values from a few specific fields in a word
document from VB.Net.

I have opened the doc and can loop through all the paragraphs...but the
table data is not returned.

Is there any way of getting the value from, say, the 3rd table, 2nd row, 1st
column.
Dim rowIndex as Long, colIndex as Long
rowIndex = 2
colIndex = 1
Dim tbl as Word.Table
Set tbl = doc.Tables(3)
string = tbl.Cell(rowIndex, colIndex).Range.Text

Note, however, that this will return two "unexpected" characters: the last
paragraph mark - Chr$(13) - and the end-of-cell marker - Chr$(7). You'll want to
trim these off the end of the string before trying to use it elsewhere.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top