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

Free Support Forum - aspose.com

Merge Fields with Spaces

We upgraded from a very old version of Aspose.Words to version 9.0.0 and I’ve noticed that if a merge field has a space in the name that it is no longer merging.

For example mergefield: {MR_CloseDate - MonthName Year} is no longer populating. I tried using the old version on an old server and it worked, so I believe the issue is caused by upgrading to 9.0.0.

I stepped through the code and the FieldName being seen is {MR_CloseDate.
Is this a known issue? If I upgrade to 9.3 and correct any breaking changes will it work?

Hi Dave,
Thanks for your inquiry.
I have tested your issue using Aspose.Words 9.0. I was able to reproduce the issue but only when the field is not enclosed within speechmarks. This is the standard behavior when you insert a field containing spaces in MS Word.
For example:
"MR_CloseDate - MonthName Year" merges correctly.
MR_CloseDate - MonthName Year does not merge correctly.
If this was indeed the issue hopefully there are not many fields like this and can be changed by hand quickly. If there is a further issue as there are too many to change manually then please tell us and we will try to provide code to achieve this instead. Sorry for any inconvience.

I was able to write a small program to go through and fix all of the affected merge codes. We will not use merge codes with spaces in them in the future.

No further assistance is required.