aduffy
February 26, 2021, 12:54am
1
I can’t get a basic if condition to work using mail merge…
This
image.png (1.7 KB)
Is outputting this
image.png (1.1 KB)
What am I doing wrong? Does Aspose.Word even support Mail Merge IF condition?
Can someone please point me to a clean example?
I’ve got a basic MVC UI that then posts to
image.png (84.3 KB)
1 Like
@aduffy ,
Please check these template and output word documents (If field Mail Merge Test.zip (18.6 KB)) and try running the following code:
Document doc = new Document("C:\\temp\\If field Mail Merge Test.docx");
// doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields;
doc.MailMerge.Execute(new string[] { "Gender" }, new object[] { "Male" });
doc.Save("C:\\temp\\21.2.docx");
1 Like
aduffy
March 1, 2021, 2:41am
3
Hey support… the outputted file 21.2 does not work. The word “male” has been merged in but the IF statement has not be evaluated / run.
@aduffy ,
In MS Word, you can press ALT+F9 to toggle between field codes and field results. Or if you always want to see IF field’s result, then you can uncomment the line containing MailMergeCleanupOptions.RemoveContainingFields
.