To add Table of contents to your document click Table of Contents buttton of Table of Contents group of References tab.
Table of contents are shown as a set of fields under Structured Document Tag.
The property of bookmarks are used to link to a particular portion of document through Table of Contents.
Consider,
<w:sdt>
<w:sdtPr>
As you can see we have a document part object of type Table of Contents,defined in the node 'docPartObj'.
The contents of table of contents appear in the content portion of the Structured Document Tag
node 'pStyle' suggests the style to be used which is in turn defined in 'styles.xml'
'fldChar' specifies that a field character shall be placed at this location in the document,which would be the page number of each topic.
Here,the appearance of the table of contents is defined by
<w:tabs>
Hi,
Yes, you need to create hyperlinks for each of the items in the content. Either you generate automatically or manually, the bookmark and hyperlinks in TOC are interlinked.
Sheela
In an application, I generate automatically a Word document using OpenXML with TOC, but page numbers are not created (or updated if I use a templateto generate my document)...
The matter is that since I don't use Word to generate my document, I could not use <w:lastRenderedPageBreak /> tags, so I have no idea of how to find in which page titles are.
Do you know how to do?
Ludo.
Since page no (no. of pages) depends on the page layout, it will be difficult to determine
the page no automatically to put in TOC. But, the point is hyperlinked item is not the page
no, it is the book mark created, hence you can link hyperlink and the book mark with random
number. I aggree, TOC numbers will not be in sync with the number pages in word document.
I guess, it will be difficult to create TOC with exact page numbers.
I'm creating a document using wordprocessingml for Word 2003.
Is there an easier way to create a TOC, but without the hyperlinks? That is, create a TOC based on the location of my headings without hyperlinks to the sections?
It would also be great if the page numbers were auto-updated when the document was opened without having any user interaction.
Thanks, Mike
I've written some code, and recorded some screen-casts that explain TOC markup in detail:
openxmldeveloper.org/.../exploring-tables-of-contents-in-open-xml-wordprocessingml-documents.aspx
-Eric
Hi...,
Numbering in table of contents into docx file is not incrementing order and PAGEREF linking is working fine.
I am facing this issue, how to increment the table of contenets number.
Ex : Right side number should be incrementing order, i am using WordProcessingML
Table Of Contents
1 Purpose and scope ........................................................1
2 Executive ...........................................................................1
3 Batches .............................................................................1
4 materials performance...................................................1
4.1 Sources.....................................................................1
4.2 Vendor ......................................................................1
Can u pls look into the bellow code and help me out this issue. I have tried bellow code in java using WordProcessingML.
public static StringBuffer addTOCEntry(StringBuffer strBuffer,
String templateName, String heading, String headingOrder,
String headingBookMark, String tocStyle) {
// Add the templates
strBuffer.append(" <xsl:template name=" + "\""
+ templateName
+ "\"> "
+ " <w:p > "
+ " <w:pPr> "
+ " <w:pStyle w:val="
+ "\""
+ tocStyle
+ "\" /> "
+ " <w:rPr> "
+ " <w:rFonts w:asciiTheme=\"minorHAnsi\" w:eastAsiaTheme=\"minorEastAsia\" w:hAnsiTheme=\"minorHAnsi\" w:cstheme=\"minorBidi\" /> "
+ " <w:noProof /> "
+ " <w:sz w:val=\"22\" /> "
+ " <w:szCs w:val=\"22\" /> "
+ " </w:rPr> "
+ " </w:pPr> "
+ " <w:r> "
+ " <w:t>"
+ headingOrder
+ " </w:t> "
+ " </w:r> "
+ " <w:szCs w:val=\"22\" /> " + " </w:rPr> "
+ " <w:tab /> " + " </w:r> " + " <w:r> "
+ " <w:rPr> " + " <w:noProof /> "
+ " </w:rPr> " + " <w:t>" + heading
+ " </w:t> " + " </w:r> " + " <w:r> "
+ " </w:rPr> " + " <w:tab /> "
+ " </w:r> " + " <w:r> " + " <w:rPr> "
+ " <w:noProof /> " + " </w:rPr> "
+ " <w:fldChar w:fldCharType=\"begin\" /> "
+ " <w:instrText xml:space=\"preserve\">PAGEREF "
+ headingBookMark + " \\h </w:instrText> "
+ " <w:fldChar w:fldCharType=\"separate\" /> "
+ " <w:t>1</w:t> " + " </w:r> "
+ " <w:r> " + " <w:rPr> "
+ " <w:fldChar w:fldCharType=\"end\" /> "
+ " </w:r> " + " </w:p> "
+ " </xsl:template> ");
return strBuffer;
}
Thanks & Regards,
Ramana.
You may need to update the field once it is open in Word. If that doesn't work, let me know and I will look at it closer.
Thanks for your replay...
if we use w:dirty="true" tag inside fldCharType for both 'begin' and 'end', It is asking update the fields in this document or not.
While opening docx file it is asking " Do you want to update the fields in this document ".
If we click 'yes' button, Update Table of Content dialog box is coming for several times if we click 'OK' button.
Without asking update line number dialog box, How to increment the number in table of contents.(if it is possible without w:dirty="true" tag).
Please help me out for this issue.
Ex:
<w:r>
<w:fldChar w:fldCharType="begin" w:dirty="true" />
</w:r>
<w:instrText xml:space="preserve">TOC \o "1-3" \h \z \u</w:instrText>
<w:fldChar w:fldCharType="separate" />
How to update the numbers in TOC using wordprocessingML without usign w:dirty tag?
Please look at Eric White's screen-casts referenced in his reply. They are very detailed and I believe they will answer your questions.