ANS: Using Word Automation to get Heading/Outline Numbers
I have just discovered where it is:
For any paragraph 'p' in the document, the heading number is contained in
p.Range.ListFormat.ListString
I hope someone else will find this useful.
Charles
"Charles Law" wrote in message
...
I have a document in the following style
1 Introduction
2 Next Heading
2.1 Sub-section
Some text ...
2.2 Another Sub-section
2.2.1 Getting deeper
3 Another Major Heading
...
My final aim is to iterate through the document in VB.NET, pick out the
headings and text and create a cleaned-up, normalised XML document.
At the moment, I am iterating through the paragraphs in the document, just
picking out the headings. When I look at the text of the heading it does
not include the heading number (which is fair enough). But, how do I
retrieve the heading number? Each heading is formatted with the
appropriate heading style for its level, so "Introduction" is Heading 1,
"Getting deeper" id Heading 3, and so on.
I could look at the outline level and work it for myself, but I presume
that Word knows what number it is going to give to a heading, and it is
this number I would like to get at.
TIA
Charles
|