This question asks about moving between headers in Word VBA, and Doc Brown kindly pointed out Selection.GoTo What:=wdGoToHeading
. When I use
ActiveWindow.Selection.GoTo wdGoToHeading, wdGoToNext
or
ActiveWindow.Selection.GoTo wdGoToHeading, wdGoToPrevious
the selection moves between Heading <n>
styles, but does not jump to custom styles I have created that have Outline levels of Level 1, 2, ... (not Body Text). Other than repeatedly calling Next wdParagraph
and testing for Range.OutlineLevel < wdOutlineLevelBodyText
, is there any way to jump between paragraphs based on outline level?
You could do this by using Outline View to only show the Outline Levels that you're interested in, then navigate between the visible paragraphs:
ActiveWindow.ActivePane.View.Type = wdOutlineView
ActiveWindow.View.ShowHeading 3
Selection.MoveDown Unit:=wdParagraph