2
Answers

How to get Numbered Headings as in word using c# code.

I am preparing a word document using C#.I am using Microsoft.Office.Interop.Word.I got stuck while numbering the paragraphs.

Suppose I have to print like this in the word document.

1. Heading1

some text is here



1.1 Sub heading1

some text is here



1.1.1 Sub heading2

some text is here



2. Heading2

some text is here



Please help me. I have tried so many things but not able to do that.
Answers (2)
1
chetan Allipur

chetan Allipur

NA 413 33.7k 7y
From the blank template, I want Numbered heading 1 to Numbered heading 5 please send me the code 
1
Madhanmohan Devarajan

Madhanmohan Devarajan

NA 6.5k 471.5k 7y
Are you trying to achieve this numbering without opening the word document physically?
 
Is there any place where you drop the word document and your dotnet application picks the document from the watch folder and does rest of the changes?
 
You may need to parse the entire word document to find the content with their style (like paragrapgh, Heading 1, Heading 2 and Subtitle etc). Then based on the array of content you can find the heading and replace it with numbers prefixed to it.
 
Hope this might be helpful for you.