#1
|
|||
|
|||
Content controls bound to custom XML not updating
I'm pulling my hair out over content controls repeated multiple times across a template, bound to a custom XML part, that are neither updating properly nor in the same manner when I test with copies of the same template.
Template Details
I'm at a loss -- any light you can shed on the problem would be greatly appreciated. If it helps, and you're so inclined, you can easily view the XML with OOXML Tools, a Chrome/Edge extension that allows you to drag the template into your browser and view the package; no zipping. Thank you. |
#2
|
|||
|
|||
First, it is counter to Word's design philosophy to put things to be edited by the user in the header/footer of a template. The headers and footers should be picking up or reflecting information in the body of the document. IMHO, better practice is usually to use a cover page to hold the first instance of the Mapped Content Controls. That page need not be printed and could even be deleted after it is filled in.
With your different even and odd, I understand the desire to use mapped CCs to have the same information in all headers and footers. Location of a CC in an even or odd header/footer should not cause problems. It is still linked to the XML part. With the CC that does not replicate:
|
#3
|
||||
|
||||
I'm not sure I would use Word's design philosophy as a relevant data point here. If you want mapped CCs in your header/footer then just do it (Nike's design philosophy).
I'm not seeing the behaviour the OP described in the dotx file that was posted. If this is not reproducible on other machines then I would investigate whether there are any macros running on that machine (perhaps try starting in safe mode and see if the problem still persists). The mention of the problem being with the last CC in the story makes me think perhaps you need to exit the CC (which writes to the xml field) before leaving the footer. You might also want to verify that the CCs are mapped to the same xml field with a macro like this. Code:
Sub AuditCCs() Dim aCC As ContentControl, aStory As Range For Each aStory In ActiveDocument.StoryRanges For Each aCC In aStory.ContentControls Debug.Print aCC.Title, aCC.Tag, aCC.Range.Text If aCC.XMLMapping.IsMapped Then Debug.Print "", "", aCC.XMLMapping.XPath End If Next aCC Next aStory End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#4
|
|||
|
|||
Thank you for the sample.
I am unsure why there is a delay in updating. Try tabbing from one to another, rather than clicking in the Content Control. My observation was that they all did update when I cycled through them. |
#5
|
|||
|
|||
Thank you for the replies, and for poking at the template.
I ran Andrew's macro to confirm that all of the content controls are mapped to the same nodes. I also rebuilt the content controls in a blank template based on a "pure," default Normal. I did a little testing and it seems to work. The only weirdness was, in one instance, when binding a node to a CC, in Developer view, only one of the blue brackets turned orange. Also, after binding CCs in the body of the doc, they didn't change to orange, but when I bound CCs to the same nodes in headers/footers, there they changed to orange, but back in the body, they didn't unless I re-mapped them to their respective nodes. Not sure if that's meaningful... I have macros in my Normal template, but none auto-run or otherwise have anything to do with XML. Still, I'll move them elsewhere and rebuild the CCs in the actual template giving me trouble. EDIT: Finally, in the past, I was tabbing/clicking out of the last CC (and the header/footer, if I was in one), but it didn't make a difference. Thanks again for taking a look. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
What is the best method to have multiple sets of bound content control in a document | VGW | Word VBA | 2 | 07-12-2018 12:15 PM |
Macro to save docx to doc that checks compatibility and converts content controls to static content. | staicumihai | Word VBA | 4 | 10-12-2016 08:23 PM |
Word XML Content Controls for custom XML output | Daedalus | Word | 1 | 11-26-2015 01:38 PM |
Updating an old form with Content Controls | Something Anon | Word | 4 | 03-26-2014 03:53 PM |
Content Controls | Sammie0Sue | Word | 6 | 11-06-2013 10:56 PM |