View Single Post
 
Old 03-24-2023, 11:59 AM
Charles Kenyon Charles Kenyon is offline Windows 11 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,464
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

(Added prior to above being posted)
Here is a macro to select the first long sentence found and suggest that it be changed. Note, even with commas added, it would trigger the suggestion.
Code:
Sub LongSentencesQuery()
    ' Charles Kenyon
    ' points out long sentences, asks for changes
    ' https://www.msofficeforums.com/174325-post3.html
    '
    Dim iMyCount As Long
    Dim i      As Long
    Const iWords As Long = 30
    Dim rSent  As range
    ' Save active document before making changes
    If Not ActiveDocument.Saved Then
        ActiveDocument.Save
    End If
    'Reset counter     iMyCount = 0
    'Set number of words
    Let iMyCount = ActiveDocument.Sentences.Count
    For i = 1 To iMyCount
        Set rSent = ActiveDocument.Sentences(i)
        If rSent.Words.Count > iWords Then
            MsgBox "The sentence: " & rSent.Text & " is long, consider breaking it up into smaller sentences."
            rSent.Select
            Exit Sub
        End If
    Next i
    Set rSent = Nothing
 End Sub
Note that this is never going to go past the first problem sentence until it is corrected. It does not suggest comma placement.
It selects the problem sentence but does not mark it.
Reply With Quote