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: <!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

<![endif]–><span style=“font-size: 12pt; font-family: “Times New Roman”;”>{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 <!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;}

<![endif]–><span style=“font-size: 12pt; font-family: “Times New Roman”;”>{MR_CloseDate.
<span style=“font-size: 12pt; font-family: “Times New Roman”;”>
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.

Thanks,

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.