Workaround for merging with IF found



Aspose does not seem to be evaluating IF within a mergefield. We found a workaround. Within your template, add this macro:

Private Sub Document_Open()
End Sub

The macro will be passed to the generated word document. Now use this syntax for your if statement:

{ IF “{ MERGEFIELD myIfMergeField* }”=“TextToCheckWith” “Text when true” “Text when false” }

Where myIfMergeField is the mergefield you wish to check on, TextToCheckWith is the value to evaluate with, and 2 text values for a true and false evaluation.

By surrounding the mergefield with quotations the merged document generates a working IF merge statement. The macro code will evaluate this field within word when the document starts.

We found this solution and hope it can help others.