Free Support Forum - aspose.com

No merging taking place

I’m looking at buying your product, and tried this example from this link and there is no merging taking place…
http://www.aspose.com/wiki/default.aspx/Aspose.Word/ExecutingMailMerge.html

The template file is attached, and this is the code I’m using:

private void Button1_Click(object sender, System.EventArgs e)
{
string fileTemplate = @“C:\TestPermissions\TestTemplate.doc”;
string fileModified = @“C:\TestPermissions\TestModified.doc”;

Aspose.Word.Document doc = new Aspose.Word.Document( fileTemplate );

// Create an array of the field names
string[] fieldNames = {"[[CustomerName]]"};
// Create an array of the field values
object[] fieldValues = {“New Name …”};

//Fill the fields in the document with user data.
doc.MailMerge.Execute(fieldNames, fieldValues);

//Save the document
doc.Save( fileModified );
}

Can you let me know if the problem is on my side?
Thanks.

Hi,

Thank you for your interest in Aspose.Word.

Please also read the following topic describing how to insert merge fields into the document:

http://www.aspose.com/wiki/default.aspx/Aspose.Word/PreparingDocument.html

Basically, you should go to the Insert menu in MS Word and select Field… to open the Field dialog. Then select MergeField from the Field names list and enter a name for the merge field in the Field name text box. And do not enclose the merge field names in double square brackets ([[…]]) neither in the template nor in code - there’s no need for them.