We have written a piece of software that processes XML out of a Word document's internal XML files, and replaces certain codes with replacement values. Sometimes we find that such codes are broken up between multiple runs. Here is an example of the sort of thing we sometimes come across:
<w:r>
<w:rPr>
<w:szCs w:val="24"/>
</w:rPr>
<w:t xml:space="preserve">After all, if you trust [CAN:Forename.ATTORNEY#01] enough to give</w:t>
</w:r>
<w:r>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
<w:t>[CAN:ObjPronoun.ATTORNEY#01</w:t>
</w:r>
<w:r>
<w:rPr>
<w:szCs w:val="24"/>
</w:rPr>
<w:t xml:space="preserve">] power of attorney, you should trust </w:t>
</w:r>
<w:r>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
<w:t>[CAN:ObjPronoun.ATTORNEY#01</w:t>
</w:r>
<w:r>
<w:rPr>
<w:szCs w:val="24"/>
</w:rPr>
<w:t>] enough to make the right decisions at the time.</w:t>
</w:r>
The paragraph starts out fine, with a full code [CAN:Forename.ATTORNEY#01]
embedded nicely in a single w:t
node, and that's perfect, but then below that, there is a w:t
node that contains the start of a code, [CAN:ObjPronoun.ATTORNEY#01
but then the w:t
tag ends, and the closing ]
is in the next run.
The user experience is that the start of the paragraph is rendered fine, in that [CAN:Forename.ATTORNEY#01]
is rendered as some person's first name. But where the user sees [CAN:ObjPronoun.ATTORNEY#01]
in their Word document, and it looks perfectly fine to them so they expect that to also be rendered as some text, we can't see that code because it's split over multiple runs, so the rendered document then still contains the code, not its replacement value.
Now to my questions....
Can anybody explain why this happens? If a user simply types in the code it's fine, but this appears to happen if they go back and fiddle about with the paragraph. Is there anything we can tell the user in the vein of "don't do this" or "don't do that", or "make sure you do such-and-such". Or are there perhaps Options in Word that prevent this from happening?
Is there an action the user can take exclusively through the MS Word front end that corrects such paragraphs? At the moment we are instructing them to highlight the entire paragraph, cutting it, pasting it into Notepad (where it loses all that weird detritus left behind from the user's modification history), copying it again from Notepad and pasting it back into Word. Yes. That works. But it's a bit ... unsatisfactory, to say the least. So if there is a native Word method for achieving the same thing, that would be a lot more elegant....