T
Tyler
I would like to know if it is possible to get the "value" of a heading that
Word is using programmatically. I will try to clarify my question with a
demonstration. If I have a document and I set it to use a numbered heading
style for its layout, I might have something that looks like:
1. Overview
2. Introduction
3. How to do it 101
3.1 Starting
3.2 Finding Help
4. Advanced Options
In this case, the leading number and period are supplied by the style, and I
simply type in the text (Overview, Introduction, etc.). When I parse this
document in VBA, I can get the style names and the text, but I'm not sure
how (if it is even possible) to get the characters Word is automatically
generating (1., 2., etc.). Outlined below is a little pseudo code to
provide an idea of where I'm currently sitting:
for each section in WordDoc.Sections
for each paragraph in section.Paragraphs
' Get the text - Overview, Introduction, etc.
text = paragraph.Range.Text
' Get the style name - Heading 1, Heading 2, etc.
styleName = paragraph.style.NameLocal
' How can I get the text Word is putting in based on the style?
<< Unknown code here >>
' Do some stuff with the information.
next
next
Any help would be much appreciated.
Thanks, Tyler
Word is using programmatically. I will try to clarify my question with a
demonstration. If I have a document and I set it to use a numbered heading
style for its layout, I might have something that looks like:
1. Overview
2. Introduction
3. How to do it 101
3.1 Starting
3.2 Finding Help
4. Advanced Options
In this case, the leading number and period are supplied by the style, and I
simply type in the text (Overview, Introduction, etc.). When I parse this
document in VBA, I can get the style names and the text, but I'm not sure
how (if it is even possible) to get the characters Word is automatically
generating (1., 2., etc.). Outlined below is a little pseudo code to
provide an idea of where I'm currently sitting:
for each section in WordDoc.Sections
for each paragraph in section.Paragraphs
' Get the text - Overview, Introduction, etc.
text = paragraph.Range.Text
' Get the style name - Heading 1, Heading 2, etc.
styleName = paragraph.style.NameLocal
' How can I get the text Word is putting in based on the style?
<< Unknown code here >>
' Do some stuff with the information.
next
next
Any help would be much appreciated.
Thanks, Tyler