G
Guest
I want to extract from a document all the headers and at least 2 lines from each paragraph of normal text in a hierarchical manner in the style of the document map. I want to extract this information to a database. I am using the following code
Dim prg As Paragrap
Dim sty As Styl
For Each prg In ActiveDocument.Paragraph
Set sty = prg.Styl
If sty.Type = wdStyleTypeParagraph Then
If prg.Style <> wdStyleNormal Then
Debug.Print "Style: " & prg.Style & vbCrLf & " Title: " & prg.Range.Tex
Next pr
When i run this code i seem to be getting pretty much all the styles from my document, but i only want the header styles and in the hierarchy they come in the document ie Header 1, Header 2, Header 2, Header 3, Header 2 etc...
Dim prg As Paragrap
Dim sty As Styl
For Each prg In ActiveDocument.Paragraph
Set sty = prg.Styl
If sty.Type = wdStyleTypeParagraph Then
If prg.Style <> wdStyleNormal Then
Debug.Print "Style: " & prg.Style & vbCrLf & " Title: " & prg.Range.Tex
Next pr
When i run this code i seem to be getting pretty much all the styles from my document, but i only want the header styles and in the hierarchy they come in the document ie Header 1, Header 2, Header 2, Header 3, Header 2 etc...