Free Support Forum - aspose.com

Creating Index in Word Document

Hi,
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.

Hi,

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.

Hi,
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.

Hi,

Here are the INDEX field codes:

http://office.microsoft.com/en-us/assistance/HP051862091033.aspx

Here are the XE (index entry) field codes:

http://office.microsoft.com/en-us/assistance/HP051862161033.aspx

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>

Hi,
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 directly.how 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(“XE.Heading:subHeading”,"");

dcBuilder.InsertField(“XE.subject:sub1”,"");

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

doc.Save(“letters.doc”,SaveFormat.FormatDocument,SaveType.OpenInBrowser,this.Response);

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.