472,348 Members | 1,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

Using Word Automation to get Heading/Outline Numbers

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
5 5587
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael G. Schneider | last post by:
I know that using Word Automation inside an ASP page is no good idea. Anything I want to do in the current project is: open document, change some...
0
by: Stephane Belzile | last post by:
Hi, I've seen a lot of people having that same problem trying to instantiate a word.application com object from an asp.net application. I have...
2
by: JP SIngh | last post by:
HI All I just wonder if anyone has created a word document using ASP. I am able to create a work document with ASP without any problem but what...
4
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my...
1
by: Rachel | last post by:
I have just started to rewrite an application using ASP.NET. One of the main features of the application is automated letter production. In the...
1
by: Rachel | last post by:
I have just started to rewrite an application using ASP.NET. One of the main features of the application is automated letter production. In the...
1
by: Jay | last post by:
Hi, I have been using word automation with .Net framework 1.1 and it works fine with windows services but when i use the same code on .Net...
0
gemmountain
by: gemmountain | last post by:
Hi, does anyone know how to use Word Automation to insert page numbers for each section in a Word document, and the numbering scheme of each section...
2
by: SaubhagyaID | last post by:
How can I translate words from one language to another (say English to German) using MS Word proofing tools through MS Word automation in C# ? I want...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.