Finding the section number

J

Jan Eliasen

Hello

I am new to VBA, and I am writing a Word-macro

I need a way to find the section number the cursor is in.

I found the wdActiveEndSectionNumber, but that seems to always return
"2" in my macro. And I need the full number. If I am in section 2.3.1
then I need a string with "2.3.1" in it. Is this possible?

Thanks in advance
 
C

Cindy M -WordMVP-

Hi Jan,
I am new to VBA, and I am writing a Word-macro

I need a way to find the section number the cursor is in.

I found the wdActiveEndSectionNumber, but that seems to always return
"2" in my macro. And I need the full number. If I am in section 2.3.1
then I need a string with "2.3.1" in it. Is this possible?
This may not be 100% reliable, but

ActiveDocument.Bookmarks("\HeadingLevel").range.ListFormat.ListString

This references an internal Word bookmark that picks up the closest
preceding paragraph formatted with a Word Heading style.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.mvps.org/word

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
W

Word Heretic

G'day Jan Eliasen <[email protected]>,

Selection.Movestart wdstory,-1

MySection=Selection.Sections.Count

:)


Jan Eliasen said:
Hello

I am new to VBA, and I am writing a Word-macro

I need a way to find the section number the cursor is in.

I found the wdActiveEndSectionNumber, but that seems to always return
"2" in my macro. And I need the full number. If I am in section 2.3.1
then I need a string with "2.3.1" in it. Is this possible?

Thanks in advance

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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