Word Forms Tables

  • Thread starter Thread starter johnb
  • Start date Start date
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
 
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
 
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
 
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
 
Hi BeWyched,
Thank you for the advice, I shall have a play with that code.

cheers johnb
 
Back
Top