Word Forms Tables

J

johnb

Hi All
How do I loop thru Word 03 document tables using VBA from within Access 03
and dump the content into a Access table . I don't seem to be able to find
any articles on the subject anyone done this before?

TIA
johnb
 
B

BeWyched

Hi Johnb

I assume you know how to create a Word object in VBA (let me know if not)
and you have set a reference to the Word library file. If so then use:

Dim wdCell as Cell
For Each wdCell In ActiveDocument.Tables(1).Columns(1).Cells
MsgBox wdCell.Range.Text
Next

This will loop through the cells in the first column of the first table in
the active document - change as appropriate. Obviously, change the MsgBox
line to coding to populate your table.

You may find that wdCell.Range.Text picks up the closing carriage
return/line feed symbol in which case use:
MsgBox Left(wdCell.Range.Text, Len(wdCell.Range.Text) - 1)
instead.

Cheers.

BW
 
J

johnb

Hi BeWyched

Thanks for those comments. Very useful. But how would I select a particular
Word table and move to the next Word table?

jonb
 
B

BeWyched

You could spin around the document's tables collection:

Dim wdCell as Cell, n
For n = 1 to ActiveDocument.Tables.Count
For Each wdCell In ActiveDocument.Tables(n).Columns(1).Cells
MsgBox wdCell.Range.Text
Next
Next n
 
J

johnb

Hi BeWyched,
Thank you for the advice, I shall have a play with that code.

cheers johnb
 

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