Hi Mystery,
> Can I somehow get all the tables in a document programatically?
You can iterate through the Tables collection:
For Each tbl in ActiveDocument.tables
> Given a table (as fetched above), can I get all the merge fields used
> within this table? (ie the ones that are on row two of the table
> template)
Continuing from above:
For each fld in tbl.Range.Fields
If fld.Type = wdFieldMergefield Then
> Failing that, given a merge field, can I see what Word table that is
> on?
Yes... with reservations. What, more specifically, would identify the
table for you? Place it in a bookmark? "look at" the column headers?
> What is the easiest way to populate the table? cell by cell (which I
> am doing) or all in one hit. If it is the latter, which method do I
> use?
Well, cell-by-cell is certainly the slowest conceivable way. My
preference is to get the data into a delimited string, assign it to the
Range.Text property, then convert the range to a table. This wouldn't
mesh too well with the existing table, however. I'd say you'd need to
delete that and put the string in its place...
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)
Mystery Man - 21 Jan 2004 06:25 GMT
Thanks Cindy
With you help, I have it working. However, as you mentioned cell by
cell is too slow. In addition, calling the method to insert a row in
the table multiple times is even slower. Therefore, I am investigating
your suggestion of putting the data into a Range.Text and then
converting it to a table. Getting the new table is easy enough.
However, we need to be able to preserve properties of the cells such
as width, alignment, font name, font size, colour, etc that are in the
original document. Can I programattically get all of these attributes
from a table and then apply them to all cells in a particular column
(except the first row) once the new table has been created?
> Hi Mystery,
>
[quoted text clipped - 35 lines]
> This reply is posted in the Newsgroup; please post any follow question
> or reply in the newsgroup and not by e-mail :-)