I have worked with this problem a lot:
In word, the document can be saved like this
<w:t>{</w:t>...
<w:t>variable</w:t>
<w:t>}</w:t>
I have therefore create a JS library that works even if variable names are splitted: Docxtemplater (works server side too) . What I have found out during development is that variables names aren't splitted if:
- The text to find is only composed of a-zA-Z characters (no {, $ or })
- The text might be splitted if the text wasn't written in one stroke: For example, if you make a spelling mistake, and write ${varuable} , then make an edit -> ${variable}, the text inside the xml is highly probably going to be splitted. Basically you have to write your variable names in one stroke, and if you wish to edit one, rewrite the variable name completely.
I don't think there's a way to fix a docx document with one command in Word, , but rewriting the variables to write them in one Stroke should work.