Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 03-25-2023, 07:18 AM
gmaxey gmaxey is offline Macro to identify and fix long sentences without commas Windows 10 Macro to identify and fix long sentences without commas Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

... but here is a crude attempt to at least process your example text:

Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oWord As Range
Dim oRngFlag As Range
Dim lngCount As Long
  Set oWord = ActiveDocument.Words(1)
  Set oRngFlag = oWord.Duplicate
  Do
    Debug.Print oWord.Characters(1)
    Select Case True
      Case oWord.Characters(1).Text Like "[A-Za-z]"
        lngCount = lngCount + 1
      Case oWord.Characters(1).Text Like "[.,:;\!\?]"
        lngCount = 0
        oWord.Select
        oRngFlag.Start = oWord.End
    End Select
    oWord.Move wdWord, 1
    oRngFlag.End = oWord.End
    If lngCount = 30 Then
      Do
        oRngFlag.MoveEnd wdCharacter, 1
      Loop Until oRngFlag.Characters.Last Like "[.,:;]"
      oRngFlag.HighlightColorIndex = wdBrightGreen
      oRngFlag.Collapse wdCollapseEnd
      lngCount = 0
    End If
  Loop Until oWord.End = ActiveDocument.Range.End - 1
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
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:34 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