We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

2up labels

Is there any example of setting up a mail merge template in word using regions and next? I need to print sheets of address labels from the database using Avery 5161 template. I am not sure how to set up the template and I can’t seem to find any clear examples or populating the data into such a template. Mailing and Address labels are a common use for database information but I can’t seem to find anything except invoices and reports.

Hi there,


Thanks for your inquiry. Please check attached ‘MailingLabelsDemo.doc’. You need to create template document with mail merge fields and Next fields. See the attached image for detail.

Following code example shows how to perform a mail merge operation for Mailing Labels. Hope this helps you. Please let us know if you have any more queries.

Document
doc =
new
Document(MyDir +
“MailingLabelsDemo.doc”);<o:p></o:p>

// Open the database connection.

string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +

DatabaseDir + "Northwind.mdb";

OleDbConnection conn = new OleDbConnection(connString);

conn.Open();

// Open the data reader.

OleDbCommand cmd = new OleDbCommand(

"SELECT TOP 50 * FROM Customers ORDER BY Country, CompanyName", conn);

OleDbDataReader dataReader = cmd.ExecuteReader();

// Perform the mail merge

doc.MailMerge.Execute(dataReader);

// Close database.

dataReader.Close();

conn.Close();

doc.Save(MyDir + "MailMerge.ExecuteDataReader Out.doc");