Merge insert data from recordset into existing word table

J

justagrunt

Hi,
I have a recordset with 22 feilds.
I have an existing word table in a document with 2 columns and 23 rows.
The first row is the headers of the columns.
Options and dollar value are the two headers.
The remaining rows in the first column are numbered 1 to 22 down.
How do I merge the data from the recordset into the 2nd column, row by row
down, into only the second column.
I can open an instance of word and open the template with the table.
I can reference the recordset.

Any pointers readily appreciated.
 
B

BeWyched

Hi

Try spinning round the table's 'Cells' property. e.g.

For each cellVal in ActiveDocument.Tables(1).Columns(2).Cells
cellVal.Range.Text = rst!yourfield
rst.movenext
Next

You will need to juggle with the (1) and (2) to get the correct
table/column. Also, you will probably need a flag to avoid populating the
first column, e.g.

cellFlag = False
For each cellVal in ActiveDocument.Tables(1).Columns(2).Cells
If cellFlag then
cellVal.Range.Text = rst!yourfield
rst.movenext
End If
cellFlag = True
Next cellVal

Cheers.

BW
 
Top