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

Free Support Forum - aspose.com

Is there a way to get FieldMergingArgs for each merge field before call MailMerge.execute()

Hello Aspose team,

I have a case where I need to prepare data in front of executing mail merge based on value returned from FieldMergingArgs.getFieldCode(). I need to know if some custom format is set then we have different data preparation logic.

It seems this API is only available in IFieldMergingCallback.

For example, I’m trying to get this value

MERGEFIELD InvoiceItem.SubscriptionNumber * MERGEFORMAT

What I can get before mail merge is only InvoiceItem.SubscriptionNumber

Any suggestions on this?

I’m with Java Aspose Word 15.2

Thanks in advance!


We suggest you please upgrade to the latest version of Aspose.Words for Java i.e. 19.3 and try running the following code:

for(Field field :(Iterable<Field>)doc.getRange().getFields() ) {
    if (field.getType() == (FieldType.FIELD_MERGE_FIELD)){
        FieldMergeField mf = (FieldMergeField) field;

In case the problem still remains, please ZIP and upload your sample input Word document here for testing. We will then investigate the scenario on our end and provide you more information.

Thanks, this is helpful.