Note that there are some explanatory texts on larger screens.

plurals
  1. POUnusual XML notations of mergefields in DOCX file.
    primarykey
    data
    text
    <p>In our document generation system we use DOCX files in which we programmatically fill out mergefields. For this I'm using the OpenXml SDK 2.0. </p> <p>I've been plowing through the document.xml file, in de docx, and found that the mergefields are usually represented by a SimpleField. An example from a document we use: </p> <pre><code>&lt;w:fldSimple w:instr=" MERGEFIELD NP021_INSSNumber \* MERGEFORMAT "&gt;&lt;w:r&gt;&lt;w:rPr&gt;&lt;w:noProof/&gt;&lt;/w:rPr&gt;&lt;w:t&gt;«NP021_INSSNumber»&lt;/w:t&gt;&lt;/w:r&gt;&lt;/w:fldSimple&gt; </code></pre> <p>A fairly straightforward notation, containing the mergefield command and the text to be displayed in the document. It's fairly easy to find this tag in the XML, just search for w:fldSimple tags. (I removed some style tags to make it more readable)</p> <p>But a document recently created in Word didn't parse in our code, and when I looked in the XML the notation for mergefields was completely different: </p> <pre><code>&lt;w:instrText xml:space="preserve"&gt; MERGEFIELD NP021_INSSNumber \* MERGEFORMAT &lt;/w:instrText&gt; </code></pre> <p>And later in the document I found the display notation: <code>&lt;w:t&gt;«NP021_INSSNumber»&lt;/w:t&gt;</code> This is spectacularly impossible to parse in code. </p> <p>How is it possible that doing the same thing in Word can have such different results, and is there a way to ensure that Word uses SimpleFields as XML notation for mergefields?</p> <p>Thank you in advance for any helpful input.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload