Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 03-24-2023, 11:59 AM
Charles Kenyon Charles Kenyon is offline Macro to identify and fix long sentences without commas Windows 11 Macro to identify and fix long sentences without commas 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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to identify and fix long sentences without commas Macro to select multiple sentences that contain a specific word MauiTruss Word VBA 7 10-03-2018 03:46 PM
Macro to identify and fix long sentences without commas Macro to number sentences tjf816 Word VBA 10 03-29-2017 05:42 PM
A Widlcard or Macro to Properly Remove Spaces Between Commas? CrossReach Word 6 01-23-2017 04:28 AM
Macro to identify and fix long sentences without commas Need a Macro that Combines Every 5 sentences into a paragraph jgarland Word 22 01-11-2012 11:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft