Would someone please tell me how to populate a Word 5 Column Table with data
retrieved from a Sql Server via ADODB connection. I would like the data to
look like a Report in Word. I know how to make the connection however I
don't know how to format it nicely in Word.
thanks,
Ted
Malcolm Smith - 20 Jan 2005 19:33 GMT
Ted
It depends on how big the table is going to be. For some of my reports
which I make I don't use tables but, rather, I use Tabs because using
tables is slower and make for fatter Word documents.
If you know how to make the Connection object then I guess that you know
how to make the RecordSet object.
So, I am not sure what you want to do next. But if you this regularly
then may I suggest that you set up a template and then create your data
report in there and then you know how it's going to look.
To populate the table you can put the selection into the first column and
the second row of the table (say it's table one) as I am assuming that row
one is for the title and then something like:
oDoc.Tables(1).Cell(2,1).range.select
Do while not oRS.EOF
selection.typetext ors("Col_01")
selection.typetext vbtab ' or whatever it is to go to the next cell
' and so on
oRS.MoveNext
loop
Something like that. But if you have the table setup in a template
first then you know how it's going to look and you don't need to change
the code each time you want to change the layout.
Hope this is a help.
- Malc
> *From:* Ted<Ted@discussions.microsoft.com>
> *Date:* Thu, 20 Jan 2005 09:35:02 -0800
[quoted text clipped - 5 lines]
> thanks,
> Ted
Alex Ivanov - 20 Jan 2005 19:47 GMT
Ted,
Create an autotext entry containing a single row of your table with
bookmarks in each field and insert that autotext for every record in the
recordset. Please look at this sample. It uses Access as a source, but will
work with any ADODB recordsets if you made proper adjustments.
http://www.aleksoft.net/samples/TestReport.zip

Signature
Please reply to NG only. This email is not monitored.
Alex.
> Would someone please tell me how to populate a Word 5 Column Table with
> data
[quoted text clipped - 4 lines]
> thanks,
> Ted