MyAdoRecSet.MoveFirst
WITH MyWordTable
FOR lnRow = lnFirstRow TO lnRecCount
FOR lnCol = 1 to lnFieldCount
.Cell(lnRow,lnCol).Range.InsertAfter
(MyAdoRecSet.Fields(lnCol - 1).Value)
ENDFOR
MyAdoRecSet.MoveNext
ENDFOR
ENDWITH
TIA,
Loraine
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
Use the Next property of the Cell to go from one cell to the next. Also,
I'd use the Text property rather than InsertAfter.
Dim oCell As Cell
Set oCell = MyWordTable.Cell(1,1)
For lnRow = lnFirstRow To lnRecCount
For lnCol = 1 to lnFieldCount
oCell.Text = _
(MyAdoRecSet.Fields(lnCol - 1).Value)
Set oCell = oCell.Next
Next nCol
Next lnRow
Regards
Dave
Loraine <loraines...@hdsinc.net.invalid> wrote in message
news:1351beaf...@usw-ex0103-024.remarq.com...
Is there is a way to grab a whole recordset record at one time
and replace a whole row in a Word table, rather than field-by-
field and cell-by-cell?
Thx again,
You might get a better response if you post to
microsoft.public.word.word97vba.
Regards
Dave
Loraine <loraines...@hdsinc.net.invalid> wrote in message
news:267e18ac...@usw-ex0103-024.remarq.com...
> Thanks Dave, I tried your suggestion but didn't find any
> measurable speed difference - that may be because my recordsets
> are not very big? Just a note that a range expression needs to
> be added to the one statement (oCell.RANGE.text = "something").
>
> Is there is a way to grab a whole recordset record at one time
> and replace a whole row in a Word table, rather than field-by-
> field and cell-by-cell?
Lorraine:
I would be sorely tempted to send the whole lot across as tab-delimited
text, then use Word's ConvertToTable Method to make the table after you have
sent all the data across.
Obviously someone at Microsoft had problems with this, because it appears
ConvertToTable has been re-coded for efficiency. It's so blindingly fast
that I smell some inline assembler in there somewhere :-)
Note: You may find a big speed improvement if you code the module in VBA in
a Word template and simply call it from FoxPro, rather than having to
support all the cross-chatting across the OLE interface, which is
notoriously slow.
Look up ConvertToTable Method in the VBA help.
Cheers.
Please post follow-up questions to the newsgroup so that all may follow the thread.
John McGhie <jo...@mcghie-information.com.au>
Consultant Technical Writer
Microsoft MVP (Word)
Sydney, Australia (GMT +10 hrs) +61 (04) 1209 1410
Regards
Dave
Loraine <loraines...@hdsinc.net.invalid> wrote in message
news:17a55ce8...@usw-ex0103-019.remarq.com...