Free Support Forum - aspose.com

How to retain my case- when I reopen the document?

I have a template document, where I gave the format to my merge field. When I create the Document from the template, text case is displaying as expected. I saved the generated document. Then I open the generated document, the data displayed is correct case. Now, I update my document and save. When I reopen the saved document again, I lost my case setting to the Merge field. the value is displaying in default case.

For instance, in my template "ClientCompleteFullNames" is a merge field with lower case. When document is created with my template, the value displays with lower case.
I updated the document, added some extra text and save changes.
When I reopen the document, I lost the case for my "ClientCompleteFullNames", it displays with it's default case.

I noticed that, when I open the document with my template
docPrecedent.Range.Text is MERGEFIELD ClientCompleteFullNames \* Lower \* MERGEFORMAT «clientcompletefullnames»
When I open the saved document
doc.Range.Text --> MR CONTACT and MRS CONTACT

Testing

How to retain my case, when I reopen the document?

Hi there,

Thanks for your inquiry. 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.

Hi team,

Here I attached the sample application source code and clickonce deployment in SampleMerge\SampleMerge\Publish folder.

Steps to recreate this problem:
1. select CM3256_Sample.docx file, provided with solution. This file is my template, where the format lower case and upper case is applied to my merge code field.
2. Press create button, to create a document CM3256_Sample_new.docx with data replaced for my merge code
3. Open CM3256_Sample_new.docx, and add some extra text by typing some thing and save the document.
4. Now select this updated document CM3256_Sample_new.docx, and press create. It creates a new file CM3256_Sample_new_new.docx,
5. Open these two files, CM3256_Sample_new.docx, and CM3256_Sample_new_new.docx,
and verify the changes to my merge code font case. I lost my font case set to lower.

Issue: With CM3256_Sample_new.docx, the placeholder is not keep up the font case setup in the initial template CM3256_Sample.docx, If I don’t modify the CM3256_Sample_new.docx, and create again I am not loosing my font case set to the merge field.

Thanks for your support.

Raveendra
Hi Raveendra,

Thanks for your inquiry. You are inserting mail merge fields in "CM3256_Sample_new.docx" without Lower and Upper field codes. See the attached image for detail. Please insert the mail merge field with Lower and Upper field codes in the document to get the desired output.

builder.MoveToBookmark(bookMarkName, false, true);

builder.InsertField(fieldCode);

doc.Range.Bookmarks[bookMarkName].Text = "";

doc.Range.Bookmarks.Remove(bookMarkName);

foreach (var linkingBookmarkName in linkingbookmarks)

{

doc.Range.Bookmarks[linkingBookmarkName].Text = "";

doc.Range.Bookmarks.Remove(linkingBookmarkName);

}

linkingbookmarks.Clear();

Thank you for your help Tahir.


What you have provided was the solution to our problem.

Kind Regards,
Jon
Hi Jon,

Thanks for your inquiry. It seems that your problem has been solved. Please let us know if you have any more queries.