xmlxsltms-wordopenxmlwordml

Office Open XML NUMPAGES field not displaying


I want to display total page count on th first page of the document. But I have encountered a problem with displaying NUMPAGES field. When I try to display TIME field everything works fine.

This code works fine and is displaying the current time:

           <w:r>
            <w:fldChar w:fldCharType="begin"/>
          </w:r>
          <w:r>
            <w:instrText xml:space="preserve"> TIME \@ "HH:mm:ss" \* MERGEFORMAT 
</w:instrText>
          </w:r>
          <w:r>
            <w:fldChar w:fldCharType="separate"/>
          </w:r>
          <w:r>
            <w:t>19:30:11</w:t>
          </w:r>
          <w:r>
            <w:fldChar w:fldCharType="end"/>
          </w:r>

But this code with NUMPAGES doesn't display the total number of pages:

           <w:r>
            <w:fldChar w:fldCharType="begin"/>
          </w:r>
          <w:r>
            <w:instrText xml:space="preserve"> NUMPAGES \* MERGEFORMAT 
</w:instrText>
          </w:r>
          <w:r>
            <w:fldChar w:fldCharType="separate"/>
          </w:r>
          <w:r>
            <w:t>19</w:t>
          </w:r>
          <w:r>
            <w:fldChar w:fldCharType="end"/>
          </w:r>

I don't understand what am I doing wrong, I do everything as written in ECMA-376 standard. Any ideas?


Solution

  • I solved the problem. The field NUMPAGES is forming correctly but the number of pages is not updated automatically. You must force it update in one of the following ways:

    1. click on the autofield and and select update field from the context menu
    2. print preview the document - the field will be updated
    3. save the document as pdf, for example