View Single Post
 
Old 01-03-2025, 11:46 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 302
vivka is on a distinguished road
Default

Hi, ADAL! Because of my scarce knowledge of VBA, I would use the following workaround to find cont. section breaks in a selected range:
Code:
Sub Find_ContSectionBrks()

Dim Rng As range
    Application.ScreenUpdating = False
    Set Rng = Selection.range
    With Rng.Find
        .ClearFormatting
       .Replacement.ClearFormatting
       .text = "^12"
       .Forward = True
       .Wrap = wdFindStop
       .MatchWildcards = True
       While .Execute
          If Rng.Characters.Last.Information(wdActiveEndPageNumber) = _
            Rng.Characters.Last.Next.Information(wdActiveEndPageNumber) Then
             Rng.Select
             Rng.InsertBefore "ContBr" 
             Selection.range.HighlightColorIndex = wdBrightGreen
             Rng.Collapse wdCollapseEnd
          End If
       Wend
    End With
    Application.ScreenUpdating = True
    Set Rng = Nothing
End Sub
You can add your 'do code' after 'Then' and delete three next lines until 'Rng.Collapse wdCollapseEnd'.
Reply With Quote