473,408 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 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 5660
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 text, save and close document. Basically changing...
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 built a WEB application that is used to manage the...
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 I want to do is slightly more than I know. I am...
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 c#-project, i want to use the system.reflection model to...
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 old application this had been accomplished using...
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 old application this had been accomplished using...
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 framework 2.0 it is not able to destroy the component....
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 is independent, not the same as previous? ...
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 to give single word (or text) as input and get...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.