How can I extract the cell content of the tables in word doc?

N

nwumengfei

Hi:
I'm working with the vba to extract some info form the tables of the
wod document. for example, there is a 3 raw and 4 col of a table,i just want
to get the 12 cells content. can you tell me a good methord?
Thankyou in advance.
 
D

Doug Robbins - Word MVP

Use:

Dim i As Long, j As Long
Dim crange As Range
With Selection.Tables(1)
For i = 1 To .Rows.Count
With .Rows(i)
For j = 1 To .Cells.Count
Set crange = .Cells(j).Range
crange.End = crange.End - 1
MsgBox "The cell in Row " & i & ", Column " & j & " contains
" & crange.Text
Next j
End With
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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