nlobak
nlobak

Reputation: 103

Create word document with headings using c#

I want to create an word documents with headings for navigation. In my c# code I created a word document and added a paragraph to it. I set the style of the added paragraph by this method:

paragraph1.Range.set_Style(document.Styles["Heading 1"]);
paragraph.Range.Text="paragraph 1";

The result of that code is a word paragraph that is text font and color are as "Heading 1" style but in the navigation pane of the word document there is no navigation tab.

Upvotes: 3

Views: 2241

Answers (1)

nlobak
nlobak

Reputation: 103

the solution was to set paragraph1.Range.Text before setting the style

paragraph1.Range.Text = "paragraph 1";
object style_name = "Heading 1";
paragraph1.Range.set_Style(ref style_name);

Upvotes: 4

Related Questions