View Single Post
 
Old 06-27-2020, 12:32 PM
alex100 alex100 is offline Windows 7 64bit Office 2016
Advanced Beginner
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default How to clear the 'OutlineLevel' property

How can I clear the 'OutlineLevel' property from all the paragraphs inside a selection, please?

The code below doesn't work, I'm just listing it here to give you an idea of what I'm looking for.

Code:
With Selection.Find
    .OutlineLevel = wdOutlineLevel1
    .Wrap = wdFindStop
    With .Replacement
        .OutlineLevel = wdOutlineLevelBodyText
    End With
    .Execute FindText:="", ReplaceWith:="", Format:=True, Replace:=wdReplaceAll
End With
Ideally, the code should match not only the first level (wdOutlineLevel1, as in the code above), but all the property levels (up to 9).

The reason I'm looking for such a routine, is that from time to time it happens that I paste some text with paragraphs that show up as headings on the navigation panel, yet they do not have a 'heading' style attached to them. I checked, and they just have this 'OutlineLevel' property set. Once I remove it, the paragraphs no longer show under the navigation panel, which is what I'm looking for.

The code should only search in the current selection (which is usually the last pasted text), not in the whole document.

Alex
Reply With Quote