Free Support Forum - aspose.com

Creating mailing labels

Hi. Is there any trick to producing templates for mailing labels in multiple columns, starting across then going down the page? Thanks.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you can use mail merge with regions and NEXT fields. For example see the following code:

//Create data source

DataTable labels = new DataTable("Labels");

labels.Columns.Add("FirstName");

labels.Columns.Add("LastName");

labels.Columns.Add("Company");

//Add data

for (int i = 0; i < 9; i++)

{

labels.Rows.Add(new object[] { "Alexey" + i.ToString(), "Noskov" + i.ToString(), "Aspose" + i.ToString() });

}

//Open the template document

Document doc = new Document(@"Test234\in.doc");

//Execute mail merge with regions

doc.MailMerge.ExecuteWithRegions(labels);

//Save document

doc.Save(@"Test234\out.doc");

Also see the attached documents. (Press Alt+F9 to see field codes)

Best regards.

									Alexey.noskov's reply is bang on, use mail merge and should work fine!<br>