Macro to locate long paragraphs

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15626
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Macro to locate long paragraphs

Post by ChrisGreaves »

In a newsletter I was tasked with splitting long paragraphs that appeared on or before page 8 into shorter paragraphs. page 8 had arrived with 3 paragraphs occupying the top half of the left-hand column, leaving 3/4 the page bare; we wanted to make use of that white space.

Many of the earlier paragraphs were over 1,500 characters long; splitting them into shorter paragraphs offered a chance to "blot up" some of the extra white space available to us.

I hooked the macro up to the Ctrl-Shift-K shortcut:

Code: Select all

Sub SelectLongestParagraph()
    Dim prg As Paragraph
    For Each prg In ActiveDocument.Paragraphs
        Dim rng As Range
        Dim lngMax As Long
        If lngMax < prg.Range.Characters.Count Then
            If prg.Range.Information(wdActiveEndPageNumber) <= 8 Then
                lngMax = prg.Range.Characters.Count
                Set rng = prg.Range
            Else
            End If
        Else
        End If
    Next prg
    rng.Select
End Sub
P.S. Pages 9 & 10, the last two pages of the newsletter, were beautifully aligned, so we wanted to make changes only to pages 1 through 7.
There's nothing heavier than an empty water bottle