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.
Unfortunately, activation email could not send to your email. Please try again.

Update .doc/.docx document mailmerge field

Thread ID:

Created:

Updated:

Platform:

Replies:

116855 Jun 19,2014 11:14 AM Jun 24,2014 04:44 AM Windows Forms 1
loading
Tags: DocIO
Simon Blais
Asked On June 19, 2014 11:14 AM

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"
or 
    "Answer4" (like if the mergefield didn't have a if condition).

Thank you in advance for your time.

Simon.


 

    

Mail merge done with : 

            var oDocTemplate = new WordDocument(docFilePath);

            oDocTemplate.MailMerge.Execute(dr);
            oDocTemplate.MailMerge.Execute(dr);
            oDocTemplate.MailMerge.RemoveEmptyParagraphs = true;
            oDocTemplate.MailMerge.RemoveEmptyGroup = true;
            oDocTemplate.MailMerge.ClearFields = true;
        
            oDocTemplate.UpdateDocumentFields();
            oDocTemplate.UpdateTableOfContents();

            oDocTemplate.Save(saveFilePath, FormatType.Docx);

Conversion done with 

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

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

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:
http://www.syncfusion.com/support/directtrac/incidents/126574

Please let us know if you have any questions.

Regards,
Sarath


CONFIRMATION

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.

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.

;