OpenXml - The "dirty=true" attribute does not update the page numbers in the toc

Anonymous
2021-07-27T13:21:02.197+00:00

In the attached document.xml file extracted from my .docx file, the "dirty = true" attribute displays the toc well but does not update the page numbers.
could someone tell me where the problem may be coming from?
Thanks in advance.
Best regards118343-document.xml

Microsoft 365 and Office | Word | For business | Windows

6 answers

Sort by: Most helpful
  1. Anonymous
    2021-09-02T16:03:14.25+00:00

    Hello,
    Does anyone have a suggestion regarding my last request?
    thanks in advance

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Anonymous
    2021-07-29T08:26:16.15+00:00

    Yes, I found this article (http://www.ericwhite.com/blog/screen-cast-exploring-tables-of-contents-in-open-xml-wordprocessingml-documents/) as well as the others and I have tested the "dirty = true" attribute in the document.xml file and the "updateFields" element in the settings.xml file because this solution is integrated in the docx file and it is the only solution that we can set up with our client. These two solutions do an update of the translation table but not of the page numbers in this translation table. On the other hand they do not seem to do the same thing as the following VB instructions which correctly update the table and the page numbers:
    ActiveDocument.TablesOfContents (1) .Update
    I'd like to know why this doesn't work with "dirty" or "updateFields" and if not, is there some other way (other open xml element or attribute) to properly update the translation table and page numbers?
    Thanks in advance.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  3. Anonymous
    2021-07-28T16:19:57.013+00:00

    So I have to ask my questions on the forum that you indicated to me rather than on the one where we are currently discussing?

    Was this answer helpful?

    0 comments No comments

  4. Anonymous
    2021-07-28T07:54:03.74+00:00

    But of course I left the attribute "dirty = true" in the document.xml file:

    <w:r>
    <w:fldChar w:fldCharType="begin" w:dirty="true"/>
    </w:r>
    <w:r>
    <w:instrText>TOC \t "H1;1;H2;2;H3;3" \b _Section100000</w:instrText>
    </w:r>
    <w:r w:rsidR="776cd4">
    <w:rPr>
    <w:noProof/>
    </w:rPr>
    <w:fldChar w:fldCharType="end"/>
    </w:r>

    Was this answer helpful?

    0 comments No comments

  5. Anonymous
    2021-07-28T07:47:31.68+00:00

    I found this on a forum and embedded it in the document.xml file I sent you:
    https://social.msdn.microsoft.com/Forums/en-US/29199b44-f033-466a-a471-6bdcfeb47e41/generating-table-of-contents-and-applying-a-custom-style?forum=oxmlsdk

    "Creating a table of contents requires some kind of layout engine in order to determine page numbers. As you may know, the Open XML SDK does not perform layout functionality. That being said, there is a way around this limitation. You can let Word update the TOC on open by doing the following to the markup:
    1-Set the dirty attribute to have a value of true within the fldChar element
    2-Set the upateFileds element in Settings.xml to be true"

    I had also integrated the "upateFileds" element in the Settings.xml file but it didn't change anything so I removed it

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.