Refresh Word Content Controls when linked CustomXml changes

Refresh Word Content Controls when linked CustomXml changes



 Aug 11 2022
5 Comments (5 New)

It is possible to link Word content controls to data in CustomXml. The values in these content controls should update when the underlying CustomXml data changes. It doesn't in Word Online and would be very helpful if it did so.

Brass Contributor

This would be a great extension

Copper Contributor

@lindalu-MSFT Is it possible to see the development roadmap? I feel like we have no idea where this product is going. And no idea how quickly features will be coming.

Copper Contributor

The 'Content Controls' not updating when the underlying 'Custom XML' changes appears to be a Word issue. the Office.JS does have code to update the custom xml via 'context.document.customXmlParts' but Word doesn't re-evaluate the content controls XPaths. This is especially apparent in the repeater content control.


The same issue happens with VSTO and VBA when the Custom Xml changes nor does this appear to have ever worked. However, in Word VBA for example I can workaround the issue by forcing a reset of the XPath in Word.


Example or Word VBA forcing an XPath refresh.

Dim cc As ContentControl
For Each cc In ThisDocument.contentControls
Dim s As String
s = cc.XMLMapping.XPath
cc.XMLMapping.SetMapping s
Next cc


Aka, Word not re-evaluating the XPath isn't specific to Office.JS. the problem is that Office.JS doesn't support all the content Controls nor has a way to force Word to re-evaluate the Content Control XPaths.


Its also worth noting that Word in its UI doesn't Allow Custom XML to be deleted or updated. It only has append so the scenario that Custom XML is updated only happens programmatically.


Therefore, I'd propose this is an issue in word should fix independent of the object model. Minimal fix would be for Word to re-evaluate the XPaths when Custom XML is updated. Hero fix/feature would be if  Word added UI to update and removed existing Custom XML in the Word UI

Copper Contributor

Additional Note: Because of the lack of way to update Custom XML controls via Office.JS it is forcing my customer to use Word VBA instead of Office.JS

Copper Contributor

If Word can't fix this can we please get an Office.JS API to force a re-evaluate of XPath mappings when the XmlContent changes. This issue really make all the work to enable CustomXML support in Office.JS throw away work.