Content Control

Is there any way to access through all content control in word document or access content control by its tag name and change the value of content control?


4 Replies 1 reply marked as answer

MR Manikandan Ravichandran Syncfusion Team August 28, 2020 03:46 PM UTC

Hi Norman,

Thank you for contacting Syncfusion support.

From the given details, we have found that your requirement is to access all the content control by iterating the word document and find the particular content control by using their tag name. Based on this we have prepared the sample application and it can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/157348/ze/FindContentControl-653844910

In this sample, we have done the following things:
1. Loads an existing Word document.
2. Iterates into all child entities and get all content controls in the document.
3. Find the specific content control using its tag name
4. Saves the Word document.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran 



PN Preethi Nesakkan Gnanadurai Syncfusion Team August 31, 2020 04:25 AM UTC

From: Norman Siboro IBN Sent: Sunday, August 30, 2020 9:57 AM
To: Syncfusion Support <[email protected]>
Subject: Re: Syncfusion support community forum 157348, Content Control, has been updated. 


Thank you for providing the code to access all content control in a document. 
But I need one more step after finding the content control which is changing the value (text) of the content control if it is plain text or multiple text, because I cannot find property 'text' in content control  

Need Your Help 




MR Manikandan Ravichandran Syncfusion Team September 1, 2020 11:39 AM UTC

Hi Norman,

Thank you for your update.

We have modified the previously provided sample to change the content control text as per your request. The modified sample can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/157348/ze/FindContentControl_Modified-1828227620

In this sample we have done the followings,
1. Load the input document
2. Find the content control from the document using Tag name.
3. After finding the content control, change the content control text with desired new text.

In Change Text method, we have done the followings.
1. If the content control is InlineContentControl, then remove the child element form thr content control and then add new text range on it with desired text.
2. If the content control is BlockContentControl means, then remove the child elements from text body part and then add new paragraph with one text range with desired text.

Please let us know if you have any other questions.

Regards,
Manikandan Ravichandran 


Marked as answer

PN Preethi Nesakkan Gnanadurai Syncfusion Team September 3, 2020 04:04 AM UTC

From: Norman Siboro IBN  
Sent: Wednesday, September 2, 2020 11:36 PM
To: Syncfusion Support <[email protected]>
Subject: Re: Syncfusion support community forum 157348, Content Control, has been updated. 


Thank you for the support and code given to us. 
It helps us a lot. 


Loader.
Up arrow icon