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

Free Support Forum - aspose.com

Conditional Mail Merge field


I couldn’t merge a conditional mail merge field
this is my syntax in word
IF{MERGEFIELD Civilite} = “Mr” “Monsieur” {IF{MERGEFIELD Civilite} = “Mme” “Madame” “Mademoiselle”}

i’m getting the field “Civilite” from database:

string dataDir = @“C:\Users\aymen\Desktop”;
strCnn = @“Data Source=C:\Users\aymen\Desktop\jdoc\GEDOCT\GEDOCT\GeDoct.sdf”;
cnn = new SqlCeConnection(strCnn);
String strSelect = "Select Civilite, NomPrenom from FicheInformation ";
DataTable data;
SqlCeCommand cmd = new SqlCeCommand(strSelect, cnn);
SqlCeDataAdapter SelectAdapter = new SqlCeDataAdapter(cmd);
data = new DataTable();
Document doc = new Document(dataDir + “PVAsmaSaid.doc”);
int counter = 1;
foreach (DataRow row in data.Rows)
Document dstDoc = (Document)doc.Clone(true);
dstDoc.Save(string.Format(dataDir + “TestFile_out{0}.doc”, counter++));

a simple merge field already worked for me but not this
Hi there,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. It does not populate merge field inside false part of IF field.

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we'll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip them and Click 'Reply' button that will bring you to the 'reply page' and there at the bottom you can include any attachments with that post by clicking the 'Add/Update' button.