Free Support Forum - aspose.com

IF formulas on Aspose.Word 7.0.0

{IF {MERGEFIELD ACT_number} <> “” {MERGEFIELD ACT_number} “empty”}


If i read the release notes of version 7.0.0 i would expect this should work now.

But it’s still not is that correct?

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I tested this on my side and all works fine. I used the following code for testing:

Document doc = new Document(@"Test001\in.doc");

doc.MailMerge.Execute(new string[] {"ACT_number"}, new object[] {""});

doc.Save(@"Test001\out.doc");

My input and output documents are attached.

Best regards.

Ok, i see some diffrences allready…


my formula:
{IF {MERGEFIELD ACT_number} <> “” {MERGEFIELD ACT_number} “empty”}

your formula:
{IF “{MERGEFIELD ACT_number}” <> “” “{MERGEFIELD ACT_number}” “empty”}


I guess Word doesn’t put these extra quotes by default, is this necesary?


Ah… i discovered the issue… after i right mouse click on the field and choose update field it shows the correct value.

Can this be done by code?

<span style=“font-size:11.0pt;mso-bidi-font-size:10.0pt;font-family:“Times New Roman”,“serif”;
mso-fareast-font-family:“Times New Roman”;mso-ansi-language:NL;mso-fareast-language:
NL;mso-bidi-language:AR-SA;layout-grid-mode:line”>



Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. There is Document.Updatefields method, which updates all fields in the document. Please see the following ink for more information:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.document.updatefields.html

I saw the difference between my field code and yours. However, I think, your field code is incorrect a bit. Let’s suppose that mergefield ACT_number has empty string as a value, In this case, your IF field code becomes incorrect, Like the following:

{IF <> "" "empty"}

But in my case it becomes correct and can be properly evaluated:

{IF "" <> "" "" "empty"}

Best regards.

OK, thanks for your reply, i’m gonna test it and let you know!

Yes it works great.

Thanks for the excellent support!