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

Free Support Forum - aspose.com

Problems to find text inside IF fields


We insert some text marks in the documents, for insert text after combining the fields, like this:

{ IF { MERGEFIELD FIELD } = 1 "Some text [TEXTMARK]" "Other text" }

With erlier versions of Aspose.Words, at least 5.2, our code worked correctly, but with the last version 8.1, once the fields are combined, the property doc.range.text returns this:

" IF 1 = 1 "Some text [TEXTMARK]" "Other text" Some text [TEXTMARK] "

You can see that the text mark has been duplicated and our code doesn't know which text mark has to be replaced.

How can we resolve this problem?


P.D.: Sorry but we have no information about what happens between versions 5.2 and 8.1


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

Thanks for your request. Aspose.Words 5.2.0 and 8.1.0 returns different values because 5.2.0 version does not support updating of IF fields, and 8.1.0 supports.

In your case condition looks like this:

{ IF 1 = 1 "Some text [TEXTMARK]" "Other text" }

Condition is true so true text should be displayed as field value. In this case, this is "Some text [TEXTMARK]".

In the document, this looks like this:

[FieldStart] IF 1 = 1 "Some text [TEXTMARK]" "Other text" [FieldSeparator] Some text [TEXTMARK] [FieldEnd]

Best regards.

Thank you very much for the explanation, now I understand better the IF fields.

We have found solutions to our problems.