Thanks!
For some reason I get a syntax error when I try your code, on the
Paragraphs(1) part of line 4 below. ("Sub or function not defined")' Here's
what I tried:
Sub test()
Dim sectionNumStr As String
ActiveDocument.Bookmarks("\HeadingLevel").Range.Select
sectionNumStr = Paragraphs(1).Range.ListFormat.ListString
MsgBox sectionNumStr
End Sub
Not sure what I did wrong...
Anyway, I think this would work only at heading level 1, based on behavior
of the following sub based on Jonathan's posting (the msgbox line is split
below but is really all one line). This gives the heading level correctly
only when at heading level 1, with the cursor in the heading or the body
text, otherwise returns blank:
Sub genBookmarkList()
MsgBox
ActiveDocument.Bookmarks("\HeadingLevel").Range.Paragraphs(1).Range.ListFormat.ListString
End Sub
Perhaps you could try your approach at levels 2 or higher? Thanks a million,
this stuff is sure confusing...
Post by Roderick O'ReganThanks a lot folks. I learnt a lot from this posting. Something I
wanted to do a couple of weeks ago. Ended up at that time doing it how
Cindy suggested.
In this case here, I played around with both Jezebel's idea and a
ActiveDocument.Bookmarks("\HeadingLevel").Range.Select
myHeading=Paragraphs(1).Range.ListFormat.ListString
Created a numbered Heading 1. Stuck a few paragraphs of Normal text
after it. Put my cursor anywhere in those Normal formatted paragraphs
and...
Bingo! Works like a dream. Might have to put a 'Collapse" command in
there somewhere...
Regards
Roderick
On Tue, 05 Jul 2005 10:03:35 +0200, Cindy M -WordMVP-
Post by Cindy M -WordMVP-Hi =?Utf-8?B?Y2hhcmxpZUxXYWxsYWNl?=,
Post by charlieLWallaceI'm trying to access the section number (actually the legal-format heading
number, using auto numbering, example 1.4.3) of the selection from within a
macro. Hard to search for this because of confusion between heading numbers
and section numbers.
Can you identify it by the style used?
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)