By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,321 Members | 1,909 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,321 IT Pros & Developers. It's quick & easy.

Using Word Automation to get Heading/Outline Numbers

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
This may help
http://www.devx.com/dotnet/Article/17358?trk=DXRSS_XML
"Charles Law" <bl***@nowhere.com> wrote in message
news:uv*************@TK2MSFTNGP11.phx.gbl...
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

Nov 21 '05 #2

P: n/a
Hi Mark

Thanks for the reply. I had seen that in fact; I think it was posted in
another thread that I stumbled into.

I have used it as my starting point for creating an xml file, and it helps
me to get things like the style name and page numbers. but unfortunately it
falls short of extracting the outline number of a paragraph.

Charles
"Mark Jones" <no**************@devnullbucket.org> wrote in message
news:41***********************@news.twtelecom.net. ..
This may help
http://www.devx.com/dotnet/Article/17358?trk=DXRSS_XML
"Charles Law" <bl***@nowhere.com> wrote in message
news:uv*************@TK2MSFTNGP11.phx.gbl...
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


Nov 21 '05 #3

P: n/a
I suppose another option is to use the table of contents object exposed by word to set up
your XML structure.

"Charles Law" <bl***@nowhere.com> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hi Mark

Thanks for the reply. I had seen that in fact; I think it was posted in
another thread that I stumbled into.

I have used it as my starting point for creating an xml file, and it helps
me to get things like the style name and page numbers. but unfortunately it
falls short of extracting the outline number of a paragraph.

Charles
"Mark Jones" <no**************@devnullbucket.org> wrote in message
news:41***********************@news.twtelecom.net. ..
This may help
http://www.devx.com/dotnet/Article/17358?trk=DXRSS_XML
"Charles Law" <bl***@nowhere.com> wrote in message
news:uv*************@TK2MSFTNGP11.phx.gbl...
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



Nov 21 '05 #4

P: n/a
Yes, a possibility, but I think it is probably maintained independently of
the body of the document, and so could get out of sync. It could also turn
into a sorting exercise, where I traverse the document and attempt to
pigeon-hole each heading as I encounter it.

Charles
"Mark Jones" <no**************@devnullbucket.org> wrote in message
news:41***********************@news.twtelecom.net. ..
I suppose another option is to use the table of contents object exposed by
word to set up
your XML structure.

"Charles Law" <bl***@nowhere.com> wrote in message
news:OF**************@tk2msftngp13.phx.gbl...
Hi Mark

Thanks for the reply. I had seen that in fact; I think it was posted in
another thread that I stumbled into.

I have used it as my starting point for creating an xml file, and it
helps
me to get things like the style name and page numbers. but unfortunately
it
falls short of extracting the outline number of a paragraph.

Charles
"Mark Jones" <no**************@devnullbucket.org> wrote in message
news:41***********************@news.twtelecom.net. ..
> This may help
> http://www.devx.com/dotnet/Article/17358?trk=DXRSS_XML
>
>
> "Charles Law" <bl***@nowhere.com> wrote in message
> news:uv*************@TK2MSFTNGP11.phx.gbl...
>> 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
>>
>>
>
>



Nov 21 '05 #5

P: n/a
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" <bl***@nowhere.com> wrote in message
news:uv*************@TK2MSFTNGP11.phx.gbl...
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

Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.