How do I get a list of all the headings in a word document by using VBA?
Why reinventing the wheel so many times?!?
A "list of all headings" is just the standard Word index of document!
This is what I got by recording a macro while adding index to the document:
Sub Macro1()
ActiveDocument.TablesOfContents.Add Range:=Selection.Range, _
RightAlignPageNumbers:=True, _
UseHeadingStyles:=True, _
UpperHeadingLevel:=1, _
LowerHeadingLevel:=5, _
IncludePageNumbers:=True, _
AddedStyles:="", _
UseHyperlinks:=True, _
HidePageNumbersInWeb:=True, _
UseOutlineLevels:=True
End Sub