yairn
12-15-2015, 08:28 AM
I am trying to create a code that will return what is the paragraph heading number the cursor is currently in.
for example if a I have an outline document with headlines and sub headlines (1, 1.1 ,1.1.1, 2 , 2.1 etc.) and the cursor is currently located inside a paragraph that its heading is 2.2.2 - i would like to create a code that will return the current location heading number (e.g. 2.2.2)
I found the following code. it works well until inside the paragraph contains only "normal" paragraphs. if the section 2.2.2 contains a bullet or numbering list inside it - the macro nwill return a "?" if the cursor is located on or after the bullet list...
how can ignore those bullt lists?
Sub Test400B()
Dim rTmp1 As Range
Set rTmp1 = Selection.Range
While rTmp1.ListParagraphs.count = 0
rTmp1.MoveStart Unit:=wdParagraph, count:=-1
Wend
MsgBox rTmp1.ListParagraphs(1).Range.ListFormat.ListString
End Sub
for example if a I have an outline document with headlines and sub headlines (1, 1.1 ,1.1.1, 2 , 2.1 etc.) and the cursor is currently located inside a paragraph that its heading is 2.2.2 - i would like to create a code that will return the current location heading number (e.g. 2.2.2)
I found the following code. it works well until inside the paragraph contains only "normal" paragraphs. if the section 2.2.2 contains a bullet or numbering list inside it - the macro nwill return a "?" if the cursor is located on or after the bullet list...
how can ignore those bullt lists?
Sub Test400B()
Dim rTmp1 As Range
Set rTmp1 = Selection.Range
While rTmp1.ListParagraphs.count = 0
rTmp1.MoveStart Unit:=wdParagraph, count:=-1
Wend
MsgBox rTmp1.ListParagraphs(1).Range.ListFormat.ListString
End Sub