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

Free Support Forum - aspose.com

Merge Field with Upper switch

We’ve got a merge field that looks like this
{MERGEFIELD COUNTY * upper}

When it merges the county field is not being converted to uppercase by the Aspose.Words engine when Word’s mail merge would do that.

Am I seeing something that indicates a problem with our Template or is Aspose.Words not handling this switch correctly?

Thanks!

Hello!

Thank you for reporting this.

Aspose.Words currently doesn’t support format switches such as *Upper or *Roman. This is a known issue. Reference number is #5260. We’ll notify you when it is fixed.

As a workaround you can capitalize the corresponding strings in your data source.

Regards,

Hello Viktor, do you have a list of the format switches that are not supported. I tried to find it in the help file for Aspose.Words but didn’t see it in there.

Thanks!

Hello Mike!

We don’t have such a list. When someone asks about switches I usually look to the source code.

Upper , Lower, Caps and FirstCap should be supported. That’s very strange if in your case Upper doesn’t take effect. Would you attach your document for inspection? There could be something unusual.

Regards,

Save Edit

Viktor, here you go. The “* upper” switch is used in the field COUNTY right at the top.

Thanks for the help!

Hi Mike!

Sorry, but I cannot reproduce the issue. In my experiment I’ve got all uppercase as expected by design. Of course I haven’t changed your template. What do we check next? Please show me your code and provide any other details that can probably affect the result.

Here is the code:

private static void TestMailMerge2()
{
    Document doc = new Document("mail_merge/County.docx");
    doc.MailMerge.Execute(new string[] { "COUNTY" }, new object[] { "Imagineland" });
    doc.Save("mail_merge/County_result.doc");
}

Regards,

Hi Viktor, I just noticed that I compiled/deployed using Aspose.Words version 200.9.03.31. I’ll try it with the version 2009.06.30 and let you know if that does it.

Thanks for your help!

Hi Viktor, I figured it out. We had an event handler for the MergeField event. It was specifically setting the MergeFieldEventArgs.Text value. I didn’t read the remarks section in the help file for this property closely enough.

Hi again!

Aspose.Words version 6.5.0 issued on June 30 is the latest. It’s a good idea to upgrade to the latest version that your license subscription allows. You can download it from here:
https://releases.aspose.com/words/net/

Have you got right with capitalization problem? If you overwrote the MergeFieldEventArgs.Text value then that’s the reason. At the handler entry it contains the text calculated by the mail merge engine. This property gives you a chance to intercept that value and change behavior by custom logic.

Regards,

Hi Viktor, yes I have gotten it resolved. It was my mistake with the MergeFieldEventArgs.Text

Thank you for your help!

Hi Mike!

Not at all. You have found the reason yourself. That’s nice. Just two days and the problem is solved J. We’ll notify you when all the switches are supported. Please feel free to share any other feedback with our team.

Regards,

The issues you have found earlier (filed as 5260) have been fixed in this update.