Your previous post said you wanted to get the text associated with the previous heading, so that's what I coded for. You made no mention of getting its numbering (ListString) instead or of not always wanting to get the heading details.
As for the line numbering, line numbers in Word start from 1 on each page. Headings are of no particular relevance in that regard. If you want to know what lines a range spans, you could use a Function such as:
Code:
Function GetLines(Rng As Word.Range) As String
'Const wdFirstCharacterLineNumber As Long = 10
With Rng
GetLines = .Information(wdFirstCharacterLineNumber)
If GetLines <> .Characters.Last.Information(wdFirstCharacterLineNumber) Then _
GetLines = GetLines & "-" & .Characters.Last.Information(wdFirstCharacterLineNumber)
End With
End Function
Accordingly, you could use code like the following to retrieve a range of data about the comments, including page & line #s, list numbering, comment text, scope text, associated heading & text:
Code:
Private Sub GetDocData(wdDoc As Word.Document)
Dim Cmnt As Word.Comment, StrScope As String, StrTxt As String
'Const wdGoToHeading As Long = 11
'Const wdActiveEndAdjustedPageNumber As Long = 1
With wdDoc
For Each Cmnt In .Comments
With Cmnt.Scope
StrScope = "Page: " & .Duplicate.Information(wdActiveEndAdjustedPageNumber) & ", Lines: " & _
GetLines(.Duplicate) & vbCr & .Text & vbCr & vbCr & "Comment: "
'With list numbering: 0 = List with no bullets, numbering, or outlining; 1 = ListNum field
'2 = Bulleted list; 3 = simple numbering; 4 = outline; 5 = mixed numbering; 6 = picture bullet
Select Case .ListFormat.ListType
Case 3 To 5
StrTxt = .ListFormat.ListString & " " & .Paragraphs(1).Range.Text
Case Else ' Needs to back up & find the previous heading
With .GoToPrevious(wdGoToHeading)
StrTxt = "Heading: " & .ListFormat.ListString & " " & .Paragraphs(1).Range.Text
End With
End Select
End With
StrScope = StrScope & Cmnt.Range.Text
MsgBox StrTxt & vbCr & StrScope
Next
End With
End Sub
which you might test in Word with a sub as simple as:
Code:
Sub Test()
GetDocData ActiveDocument
End Sub
For use with late binding, simply change 'Word' in the above Sub & Function to whatever other variable name you've assigned to the Word application and uncomment the Const expressions.
Note that, as yet, the GetDocData sub only outputs a message box display; I have no information about how you want to process the output.
As for your (2), it's not clear what you mean about a section number. In Word, a Section is a range delimited via Section breaks at either end (except for the first and last Sections).