Reading table of contents from a word file RRS feed

  • Question

  • User735790185 posted


                 I am Navaneeth and new to web development. I have a doubt and hope someone answers my doubt. Here it is. I have a first page with a file uploader and a Ok button. When I select a word file and click the OK button it displays the table of contents of the word file in the second page. I know that there is a feature of creating Table of Contents in a word document automatically. But how do I create Table of Contents for a word file using asp.net(c#). Can someone help me regarding this.?


    Wednesday, September 17, 2008 2:19 AM

All replies

  • User1687629711 posted

    I am assuming you want to create a table of contents in a Word document ... if so this is how you do it 


    Tuesday, September 23, 2008 12:43 PM
  • User1687629711 posted

    There is also help in MSDN on this topic



     private void DocumentTablesOfContents()
        this.Paragraphs[1].Range.Text = "Heading 1";
        this.Paragraphs[2].Range.Text = "Heading 2";

        object Style1 = Word.WdBuiltinStyle.wdStyleHeading1;
        this.Paragraphs[1].set_Style(ref Style1);

        object Style2 = Word.WdBuiltinStyle.wdStyleHeading2;
        this.Paragraphs[2].set_Style(ref Style2);

        object HeadingLevel = 1;
            ref missing, ref HeadingLevel, ref HeadingLevel,
            ref missing, ref missing, ref missing, ref missing,
            ref missing, ref missing, ref missing, ref missing);


    Wednesday, September 24, 2008 6:50 AM