M
Mystery Man
This posting relates to using MailMerge fields to populate a Word
table.
I am using MergeFields as placeholders (like bookmarks) for tabular
data as well as single fields. I can get single fields populated very
easily by simply iterating through the Merge fields and replacing them
with the appropraite data.
Populating the table gets more complicated. I setup a Word table that
has 2 rows and a fixed number of columns. Row one contains the table
header as it appears to the user. In each column of the second row, I
place a merge field that ultimately relates to a column in a dataset.
This works to a fashion when populating the table, but the way I have
done this is a bit messy and not bullet proof. I would really like to
do either rewrite this or do some extra checking to ensure that a
merge field that is only relevant for a table is within a table and
the same in reverse.
The specific questions that I have are as follows (in relation to the
above):
Can I somehow get all the tables in a document programatically?
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)
Failing that, given a merge field, can I see what Word table that is
on?
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?
I hope all of this is clear.
table.
I am using MergeFields as placeholders (like bookmarks) for tabular
data as well as single fields. I can get single fields populated very
easily by simply iterating through the Merge fields and replacing them
with the appropraite data.
Populating the table gets more complicated. I setup a Word table that
has 2 rows and a fixed number of columns. Row one contains the table
header as it appears to the user. In each column of the second row, I
place a merge field that ultimately relates to a column in a dataset.
This works to a fashion when populating the table, but the way I have
done this is a bit messy and not bullet proof. I would really like to
do either rewrite this or do some extra checking to ensure that a
merge field that is only relevant for a table is within a table and
the same in reverse.
The specific questions that I have are as follows (in relation to the
above):
Can I somehow get all the tables in a document programatically?
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)
Failing that, given a merge field, can I see what Word table that is
on?
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?
I hope all of this is clear.