Get the current number

L

Lin

Hello,

I've created an autonumber in my document and now i want to know how can i
get the current number of the section that the user is standing on (with a
macro of course).

thanks - Lin
 
S

Stefan Blom

Getting information about the "current" numbering (from a certain
style) can be as easy as using a STYLEREF field; see Word Help for
more.

If you need a macro solution, there are several possibilities:

To get information about the number formatting of the *current*
paragraph, you can use the techniques presented at
http://word.mvps.org/faqs/numbering/ListString.htm.

You can apply the tips of that article to the current heading level by
using the "\headinglevel" bookmark. For example:

x = ActiveDocument.Bookmarks("\headinglevel") _
..Range.ListFormat.ListString

If you want to locate a *specific* heading level, though, a more
advanced approach is needed. One way would be the following: Starting
at the currently selected paragraph, you can use the Previous method
(Paragraph class) to loop backwards, paragraph by paragraph (without
changing the selection), until the desired heading level/numbering
level is found, and retrieve its numbering properties, as above.

I'm not sure if this is the only and/or best approach, though. If you
don't get a "more complete" answer here, you might want to ask in a
programming newsgroup instead.

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top