J
Jeff Cochand
Hi,
I have what I think is a very basic mailmerge question.
I want to write a C# program that merges myTemplate.doc with a db
table, tablePeople. The result will be a multipage word doc that can
be printed out.
The user will simply push a button in the C# program, resulting in all
the first names in the SQL Server table, tablePeople, merging with the
word doc, myTemplate.doc.
myTemplate.doc looks something like this:
Dear <<firstName>>
Please read this doc.
Sincerely, Jeff
tablePeople has several rows of firstName, lastName, address, etc.
I have http://support.microsoft.com/default.aspx?scid=kb;EN-US;301659
running on my system, but I don't have a general understanding of
programmatically merging documents. Is there a good overview of this
somewhere?
• Can I simply use an already created template doc, rather than
creating one on the fly?
• How does the template doc get associated with the datasource?
• wrdSelection.Range – Is this the key setting indicating that the
merge process should look in the datasource & template file for
whatever the parameter is set to: (ie
wrdMergeFields.Add(wrdSelection.Range, "FirstName"); )?
• wrdApp.Selection – Is this the data source? In this case it's the
same word doc as we write to? Could this be a database?
• wrdDoc.MailMerge – Is this the MS Word doc where the resulting
merged document will be written?
Thanks,
Jeff
I have what I think is a very basic mailmerge question.
I want to write a C# program that merges myTemplate.doc with a db
table, tablePeople. The result will be a multipage word doc that can
be printed out.
The user will simply push a button in the C# program, resulting in all
the first names in the SQL Server table, tablePeople, merging with the
word doc, myTemplate.doc.
myTemplate.doc looks something like this:
Dear <<firstName>>
Please read this doc.
Sincerely, Jeff
tablePeople has several rows of firstName, lastName, address, etc.
I have http://support.microsoft.com/default.aspx?scid=kb;EN-US;301659
running on my system, but I don't have a general understanding of
programmatically merging documents. Is there a good overview of this
somewhere?
• Can I simply use an already created template doc, rather than
creating one on the fly?
• How does the template doc get associated with the datasource?
• wrdSelection.Range – Is this the key setting indicating that the
merge process should look in the datasource & template file for
whatever the parameter is set to: (ie
wrdMergeFields.Add(wrdSelection.Range, "FirstName"); )?
• wrdApp.Selection – Is this the data source? In this case it's the
same word doc as we write to? Could this be a database?
• wrdDoc.MailMerge – Is this the MS Word doc where the resulting
merged document will be written?
Thanks,
Jeff