Free Support Forum -

Creating Index in Word Document

I am using Aspose.word . I would like to know is this possible to create index in the word document.The Index is just like the index of front of the Book.
It is possible in MS Word. But i didn’t find any option like this in Aspose.word
Could you tell me is possible or not.


You can insert the INDEX field with DocumentBuilder.InsertField. Please see MS Word documentation to learn the syntax of this field. Note that the field content will not be calculated (index not populated) until you refresh all the fields or print the document.

Also, you probably need to use another field (something for index entry) to mark items in the document that will make it into the index entry.

Thank you for response.
Could you give me the example of creating index in word document in aspose.word
using DocumentBuilder.insertfield.Becasue I couldn’t find any information about the indexes in aspose.word Documentation.
Also,you told that we create one more field for indexentry.I didn’t get it.could you
expalin this.


Here are the INDEX field codes:

Here are the XE (index entry) field codes:

Also, you can do this: create the index in the MS Word manually, turn show formatting marks on (press Paragraph mark button on the Standard toolbar) and press Alt-F9 to view field codes. See how the fields look like in the document and insert similar programmatically.

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p> </o:p>

I used Document.insertField to insert to the Index entries but it generates error.
I am attaching the error page to this document.
I used the Document.TableOfContents but after generating press the Alt+F9 then only it’ll show the index.But i want to show it is possible.
i am also specifying the code for u r reference.

Document doc =new Document(strDoc);

DocumentBuilder dcBuilder=new DocumentBuilder(doc);



dcBuilder.InsertField("INDEX “e"c"z “,””);


Here Heading,subject are titles of the Document.and subHeading,sub1 are subtitle of the Document.
so could you tell me how to solve it.

I’ve replied to you in email. I suggest we discuss the issue in one place only. In the forums or in email - it is your choice. You are talking to the same people and posting many times does not help to speed up the process.