![]() |
#2
|
||||
|
||||
![]()
I think you are confused about how the CollapsedState command works. You apply that command to the heading and it will collapse all of the lower level paragraphs under it. So you don't actually need to loop anything if you only want to collapse to the preceding heading.
Code:
Sub CollapseOutlinesWithinHeading() 'Go to preceding heading and collapse it Dim rngHeading As Range Set rngHeading = Selection.GoTo(What:=wdGoToHeading, Which:=wdGoToPrevious) rngHeading.Paragraphs(1).CollapsedState = True End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Loop through all shapes in all stories not working | Peterson | Word VBA | 5 | 03-04-2018 11:02 AM |
![]() |
wlcdo2 | Excel Programming | 2 | 02-22-2017 05:10 PM |
![]() |
tinfanide | Word VBA | 5 | 01-17-2013 06:02 PM |
Loop through folder of workbooks and copy range to other workbook | Snvlsfoal | Excel Programming | 3 | 07-29-2011 05:55 AM |
While loop not working right | Cbrehm | Excel Programming | 0 | 05-11-2011 11:05 AM |