DocIO: How to delete a FieldDocVariable but keeping the fields result as static content

Hi!

In Word VBA there is the Unlink function which is used to "fix" a field by deleting the field itself and converting the content/result to static content.
See: https://docs.microsoft.com/de-de/office/vba/api/word.fields.unlink

How can I do this with DocIO preserving the formatting and taking care that a (doc variable) fields content/result can contain more than a single paragraph?

In other words: I want to remove a doc variable field, but the current content of the docvariable should remain as static text with the same formatting as before so that the document looks like before but the content isn't related to a doc variable anymore.

Thanks in advance!
Chris

3 Replies

MR Manikandan Ravichandran Syncfusion Team February 18, 2020 02:23 PM UTC

Hi Chris,

Thank you for contacting Syncfusion support.

Currently, we are implementing the “Unlink” function to remove the field code and converting the content/result to static content We have planned to include this feature in 2020 Volume 1 Main release which will be available on end of March.

The status of this feature task can be tracked through the below link:
https://www.syncfusion.com/feedback/11419/remove-the-field-codes-and-preserve-field-result-alone-in-the-word-document

As a workaround, we have prepared a sample to remove the fields and preserved text alone to meet your requirement which can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/151642/ze/WinFormsApp1781515648

In this sample we have done the following.
1. Open the template Word document.
2. Execute the mail merge (already in given sample)
3. Iterate all elements in the word document
4. Get the fields and remove the field code part.
5. Saves the Word document.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran



CH Christian February 18, 2020 05:03 PM UTC

Oh, great news. Thanks for the infos!


PN Preethi Nesakkan Gnanadurai Syncfusion Team February 19, 2020 07:08 AM UTC

Hi Chris, 
  
Most welcome. 
  
Regards, 
Preethi 


Loader.
Up arrow icon