0
Reply

Word mail merge using datatable

Anthony Clarke

Anthony Clarke

Jan 14 2011 5:07 AM
9.9k

Hi,
Im new to using word with C# and was wondering whether you could help me.
I need to make a mail merge from a datatable....e.g.
Datatable is source from an SQL server e.g. Name, Address, PostCode.
And here is my code for word so far. How do i go about inserting and printing everything - well say i have 5 records..
Thanks for your time
namespace
ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
dynamic wordApp = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application"));
dynamic document = wordApp.Documents.Add();
document.Activate();
document.Content.InsertAfter(
"Type what i want");

wordApp.Visible =
true;