none
VSTO Word 2010 - Adding Element in the Navigation Pane RRS feed

  • Question

  • Hello,

    I am currently willing to add a Paragraph into the navigation pane. 

    I have not been able to find any answer on the internet to find how doing this.

    Paragraph par = AddParagraphAfterLastPosition();
    par.set_Style("Heading 1");

    My code is adding the Heading 1 style to the paragraph which affects the look but do not add it to the navigation.

    Any help is greatly appreciated. Also if you have any good tutorial concerning Word and VSTO I would love to read it.

    Sincerely,

    Linvi

    Wednesday, March 27, 2013 3:37 PM

Answers

  • Hi Linvi

    Next to your name I see the tag "Microsoft France". If you're working with a French user interface then the style name won't be "Heading 1", it will be the French language equivalent.

    It might be better for you to work with the built-in Style Enumeration Word.WdBuiltInStyle.wdStyleHeading1 instead of a hard-coded string.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    • Unmarked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    • Marked as answer by Cindy Meister MVPModerator Tuesday, April 2, 2013 10:01 AM
    Thursday, March 28, 2013 11:39 AM
    Moderator
  • Hi Linvi

    The Navigation Pane should automatically display all paragraphs formatted with the built-in heading styles. We are talking about the FIRST tab of the Navigation Pane, correct? And you've added text to the paragraph (so that there's something to show in the pane)?

    If type a new paragraph in the document and apply the same style (manually, not using code) does that show up in the Navigation Pane?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    Saturday, March 30, 2013 6:58 AM
    Moderator
  • Hi Cindy,

    Thank you for responding, I have been able to find how to fix my problem.

    The problem was not happening when I use the Style in Word. While the style was displayed for all the text in the paragraph, only the "\r" had the Style applied and consequently it did not show up in the Navigation Pane.

    Thank you for your help.

    Sincerely,

    Linvi

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    Tuesday, April 2, 2013 8:31 AM

All replies

  • Hi Linvi

    Next to your name I see the tag "Microsoft France". If you're working with a French user interface then the style name won't be "Heading 1", it will be the French language equivalent.

    It might be better for you to work with the built-in Style Enumeration Word.WdBuiltInStyle.wdStyleHeading1 instead of a hard-coded string.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    • Unmarked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    • Marked as answer by Cindy Meister MVPModerator Tuesday, April 2, 2013 10:01 AM
    Thursday, March 28, 2013 11:39 AM
    Moderator
  • Hi Cindy,

    Thank you for your answer. I changed my code to :

    par.set_Style(WdBuiltinStyle.wdStyleHeading1);

    While using set_Style, I am still unable to see the element in the Navigation Pane. This just adds the style to the paragraph.

    Any help with adding the element to the Navigation Pane?

    Linvi

    Thursday, March 28, 2013 12:17 PM
  • Hi Linvi

    The Navigation Pane should automatically display all paragraphs formatted with the built-in heading styles. We are talking about the FIRST tab of the Navigation Pane, correct? And you've added text to the paragraph (so that there's something to show in the pane)?

    If type a new paragraph in the document and apply the same style (manually, not using code) does that show up in the Navigation Pane?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    Saturday, March 30, 2013 6:58 AM
    Moderator
  • Hi Cindy,

    Thank you for responding, I have been able to find how to fix my problem.

    The problem was not happening when I use the Style in Word. While the style was displayed for all the text in the paragraph, only the "\r" had the Style applied and consequently it did not show up in the Navigation Pane.

    Thank you for your help.

    Sincerely,

    Linvi

    • Marked as answer by linvỉ Tuesday, April 2, 2013 8:32 AM
    Tuesday, April 2, 2013 8:31 AM