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

Free Support Forum - aspose.com

Show "Invalid Merge Field" dialog when merge field does not match with the datasource field

Hi,

We are using Aspose.Word to convert MS Word documents to PDF. Before converting Word document to PDF we do merge functionality on it.

I want to know that: Is there any way to show "Invalid Merge Field" dialog like in Word when merge field does not match with the datasource field. And using that dialog we can replace that merge field with another datasource field or remove that field from document and in this way we can correct our document for merging.

Hello

Thanks for your request. I think in your case you should use MappedDataField to automatically map between names of fields in your data source and names of mail merge fields in the document.

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-use-advanced-mail-merge-features.html

Also please see the following link to learn how to rename mergefields in the document:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/howto-rename-merge-fields.html

Hope this helps.

Best regards.

Hi

Thanks for your quick reply.

I have checked both link as you mentioned in your reply but in that example static mapping is done. So is there any way by which it can automatically identify Invalid Merge Fields and display a list?

Hi


Thanks for your inquiry. You can use GetFieldNames method to get list of merge fields in the document. Please follow the link to learn more about this method:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.reporting.mailmerge.getfieldnames.html

And then you can compare this list with the list of field names of your data source.



Best regards,