Hi
have you got any sample code for something like iterating through a word template with fieldtext type mergefields and replace them with data please?
Much Thanks
John
Hi John,
Thanks for your query. Aspose.Words can generate documents from templates with mail merge fields. The data from an external source like a database or file is placed into these fields and formatted, and the resulting document is saved in the folder you specify.
Please read following documentation links for your kind reference. Let us know if you have any more queries.
https://docs.aspose.com/words/net/mail-merge-and-reporting/
https://docs.aspose.com/words/net/types-of-mail-merge-operations/
Excellent thank you so much for this. BUT in word 2003 we iterated around the FORMTEXT items/controls in a mail-merge replace sort of way. Will the below commands work for doc’s saved as word 2003 with FIELDTEXT type mail merge fields?
MUCH THANKS
John
// Fill the fields in the document with user data.
doc.MailMerge.Execute(
new string[] {"FullName", "Company", "Address", "Address2", "City"},
new object[] {"James Bond", "MI5 Headquarters", "Milbank", "", "London"});
Hi John,
Thanks for sharing the information. In your case, You need to use FormField.*Result*
* Property. Please check the following code snippet for your kind reference. Please let us know if you have any more queries.
Document doc = new Document(MyDir + "in.doc");
foreach (FormField formField in doc.Range.FormFields)
{
if (formField.Type.Equals(Aspose.Words.Fields.FieldType.FieldFormTextInput))
formField.Result = "My name is " + formField.Name;
}
doc.Save(MyDir + "AsposeOut.doc");
Please read following documentation for further details.
https://docs.aspose.com/words/net/working-with-form-fields/
https://reference.aspose.com/words/net/aspose.words.fields/formfield/
Hi John,
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.