Merge insert data from recordset into existing word table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

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

Back
Top