A family of Microsoft word processing software products for creating web, email, and print documents.
I don't think the fix above from ShardulKulkarni works, for me it changed the behaviour so that instead of getting a paragraph reference (e.g. 2.3.4 The Title), you get the whole text of the paragraph.
I got this Error 91 when there was a comment on an object (like the title field) at the beginning of the document. I fixed it with the addition of an exit clause to the loop, that checks for a null previous paragraph. You end up with a reference of "General", which you could change if you want.
Function ParentLevel(Para As Word.Paragraph) As String
'From Tony Jollans
' Finds the first outlined numbered paragraph above the given paragraph object
Dim ParaAbove As Word.Paragraph
Set ParaAbove = Para
sStyle = Para.Range.ParagraphStyle
sStyle = Left(sStyle, 4)
If sStyle = "Head" Then
GoTo Skip
End If
Do While ParaAbove.OutlineLevel = Para.OutlineLevel
Set ParaAbove = ParaAbove.Previous
If (ParaAbove Is Nothing) Then
ParentLevel = "General"
Exit Function
End If
Loop
Skip:
strTitle = ParaAbove.Range.Text
strTitle = Left(strTitle, Len(strTitle) - 1)
ParentLevel = ParaAbove.Range.ListFormat.ListString & " " & strTitle
End Function