A
andreas
Below macro is showing all the sections of a document with their
respective first paragraph headings in a Message Box. It is working
fine. But ... please scroll down past the macro ...
Sub ShowSections()
Dim rnge As Range
Dim i As Long
Dim strHeadings As String
strHeadings = ""
With ActiveDocument
For i = 1 To .Sections.Count
Set rnge = .Sections(i).Range
rnge.End = rnge.End - 1
strHeadings = strHeadings & "Section " & i & ": " &
rnge.Paragraphs(1).Range.Text
Next i
End With
MsgBox strHeadings
End Sub
Now, here comes my question:
Some of these first paragraph headings feature the built-in numbering
(built-in numbered heading 1 paragraph style), like the following
example shows:
Section 1: Cover Sheet
Section 2: Table of Contents
Section 3: 1. Introduction
Section 4: 2. Relative Analysis
Section 5: 3. Conclusion
Section 6: Appendix
Section 7: Bibliography
How do I have to re-write above macro that the numbering is shown as
well? Now only the text of the headings that are positioned at the top
of each section are shown, but their numbering (1., 2., 3., etc.)
where applicable should show as well.
Help is appreciated. Thank you very much in advance.
respective first paragraph headings in a Message Box. It is working
fine. But ... please scroll down past the macro ...
Sub ShowSections()
Dim rnge As Range
Dim i As Long
Dim strHeadings As String
strHeadings = ""
With ActiveDocument
For i = 1 To .Sections.Count
Set rnge = .Sections(i).Range
rnge.End = rnge.End - 1
strHeadings = strHeadings & "Section " & i & ": " &
rnge.Paragraphs(1).Range.Text
Next i
End With
MsgBox strHeadings
End Sub
Now, here comes my question:
Some of these first paragraph headings feature the built-in numbering
(built-in numbered heading 1 paragraph style), like the following
example shows:
Section 1: Cover Sheet
Section 2: Table of Contents
Section 3: 1. Introduction
Section 4: 2. Relative Analysis
Section 5: 3. Conclusion
Section 6: Appendix
Section 7: Bibliography
How do I have to re-write above macro that the numbering is shown as
well? Now only the text of the headings that are positioned at the top
of each section are shown, but their numbering (1., 2., 3., etc.)
where applicable should show as well.
Help is appreciated. Thank you very much in advance.