We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Update .doc/.docx document mailmerge field

Thread ID:





116855 Jun 19,2014 03:14 PM UTC Jun 24,2014 08:44 AM UTC WinForms 1
Tags: DocIO
Simon Blais
Asked On June 19, 2014 03:14 PM UTC

Good day,

I'm trying to use a .doc/.docx as a template for mail merge and then convert it to PDF.

It is possible to force the behavior of CTRL+A, F9 (Update all fields) before doing the conversion or during mailmerge or that the mailmerge output of syncfusion to be the final result of the mailmerge.

Exemple : 

Word Document : Field :
    {IF "{MERGEFIELD Test1}" = "Answer1" "" "{IF "{MERGEFIELD Test2}" = "Answer2" "Anwser3" "Answer4"}"} 

Output : if (Test1 = "Answer2" and Test2 !="Answer1")
    {IF "Answer2" = "Answer1" "" "{IF "Answer1 = "Answer2" "Anwser3" "Answer4"}"} and show nothing since not updated.
    after manually updating all field (CTRL+A, F9) it show "Answer4".

Expected Output 
    {IF "Answer2" = "Answer1" "" "{IF "Answer1" = "Answer2" "Anwser3" "Answer4"}"} and show "Answer4"
    "Answer4" (like if the mergefield didn't have a if condition).

Thank you in advance for your time.




Mail merge done with : 

            var oDocTemplate = new WordDocument(docFilePath);

            oDocTemplate.MailMerge.RemoveEmptyParagraphs = true;
            oDocTemplate.MailMerge.RemoveEmptyGroup = true;
            oDocTemplate.MailMerge.ClearFields = true;

            oDocTemplate.Save(saveFilePath, FormatType.Docx);

Conversion done with 

            var wordDoc = new WordDocument(docFilePath);
            var converter = new DocToPDFConverter();
            var pdfDoc = converter.ConvertToPDF(wordDoc);

Sarathkumar V [Syncfusion]
Replied On June 24, 2014 08:44 AM UTC

Hi Simon,

Thank you for using Syncfusion products.

Update fields behavior (CTRL+A, F9) of MS Word is already implemented in DocIO by calling the UpdateDocumentFields() method. MailMerge.Execute() will performs replacements of every merge field in the document with data from the data source. If you call the UpdateDocumentFields() method before executing the mail merge the fields are updated using existing values. After executing the mailmerge, DocIO uses the populated values to update the fields.

In your given nested if field scenario we have found the issue in updating field result and we have forwarded this to our developer for further analysis. We have created a new incident #126574 for further follow ups. Kindly follow the incident #126574 to get resolved the mentioned issue.

Incident Link:

Please let us know if you have any questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon