Hello again,
I have discovered an oddity in DocIO. I have created a Word document with
InInlineContentcontrols.
When
setting the value in a ContentControl programmatically using your demo method
'ReplaceTextInInlineContentcontrol' both the placeholder text
and the user entered text in the contentcontrol are changed - and set to the same
value.
This code is where the 'magic' happens using DocIO demo code.
inlineContent.ParagraphItems.Clear();
WTextRange textRange = new(inlineContent.Document);
textRange.Text = text;
I
have created a small .Net Framework 4.8 VSTO application to see the
values of the contentcontrol.PlaceholderText and the contentcontrol.Range.Text parameters on
the same contentcontrol (using VSTO). These parameters should have held different values,
but after writing to the contentcontrol with DocIO, they are set to the same value.
Another way to
see this is by clicking the Design Mode in Word on the developer tab in a
document that has ContentControls. See this explanation: https://gregmaxey.com/word_tip_pages/modify_cc_placeholder_text.html how this would work. After using DocIO to set the value of the contentcontrol, the placeholdertext is also changed in Word.
Is there a way in DocIO to only write to the user defined text of a content control, without changing the value of the placeholder text?
Kind regards,
Niels van Strien
Hello Lokesh,
Thanks for the update.
I have spent a day looking at the OpenXML SDK for a solution. By chance I stumbled upon this project:
https://github.com/tfsbuildextensions/BuildManager
It contains an OpenXML SDK based document processing library, accessing content controls using OpenXML. There is a method here: https://github.com/tfsbuildextensions/BuildManager/blob/master/Manager/TfsBuildManager.WordDocumentGenerator.Library/OpenXmlHelper.cs
line 339
public static void SetContentOfContentControl(SdtElement contentControl, string content)
that accesses the correct text part of the ContentControl, although it does not leave the custom placeholder text in tact either. This method blanks the placeholder and sets the correct text part. I believe there is also a method to set the placeholder, but I have not had the time to test that.
Although syncfusion has a proprietary solution with DocIO, it is compatible with the methods in this library.
Perhaps this is useful information wrt this particular query, and therefore I decided to share this with you..
Kind regards,
Niels van Strien
Hello Lokesh,
Thank you for researching this issue.
I can update to the latest release of DOCIO if that is of any help.
Kind regards,
Niels van Strien