Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

How to Obtain the Generated Text of a Style

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tyler - 02 Feb 2005 12:23 GMT
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
Dave Lett - 02 Feb 2005 12:41 GMT
Hi Tyler,

I'm not sure how it will fit into your pseudo code (i.e., "based on style"),
but I thought you might find the following useful:

With Selection.Paragraphs(1).Range.ListFormat
   Debug.Print .ListString
End With

HTH,
Dave

> 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
[quoted text clipped - 33 lines]
>
> Thanks, Tyler
Tyler - 02 Feb 2005 15:52 GMT
Thank you, that is awesome!  It's exactly what I was looking for.  Do you
have any good reference material/web sites you would recommend for figuring
out this sort-of information?

Thanks, Tyler

> Hi Tyler,
>
[quoted text clipped - 51 lines]
>>
>> Thanks, Tyler
Dave Lett - 02 Feb 2005 16:18 GMT
Hi Tyler,

This sort of information? Well, no, I don't. I like the Word MVPs site
(http://word.mvps.org/), but I don't think this is addressed there. For this
one, I simply knew that I needed to poke around with "List" and see what I
could stumble upon.

Dave

> Thank you, that is awesome!  It's exactly what I was looking for.  Do you
> have any good reference material/web sites you would recommend for figuring
[quoted text clipped - 57 lines]
> >>
> >> Thanks, Tyler
Klaus Linke - 08 Feb 2005 19:05 GMT
> Hi Tyler,
>
[quoted text clipped - 4 lines]
>
> Dave

It's there in the MVP FAQs, but maybe hard to find if you don't know already
what to search for (say, ListString):
http://www.word.mvps.org/faqs/numbering/ListString.htm

Regards,
Klaus
Dave Lett - 09 Feb 2005 11:37 GMT
I stand corrected, thank you.

Dave

> > Hi Tyler,
> >
[quoted text clipped - 11 lines]
> Regards,
> Klaus
Klaus Linke - 09 Feb 2005 16:18 GMT
Hi Dave,

I didn't find it easily, either. I just *knew* it was there and kept looking.
And you said you *thought* there wasn't an article, so no correction was called
for...

;-)  Klaus

> I stand corrected, thank you.
>
[quoted text clipped - 15 lines]
> > Regards,
> > Klaus
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.