Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #22  
Old 01-11-2012, 11:01 AM
macropod's Avatar
macropod macropod is offline Need a Macro that Combines Every 5 sentences into a paragraph Windows 7 64bit Need a Macro that Combines Every 5 sentences into a paragraph Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi jgarland,

There was some serious scope creep in those last two posts - especially the last one. Try:
Code:
Sub ParaMerge()
Application.ScreenUpdating = False
Dim Rng As Range
With ActiveDocument
  Set Rng = .Range
  Rng.Start = .Range.Paragraphs(2).Range.Start
  With Rng
    With .Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "(*)^13(*)^13(*)^13(*)^13(*^13)"
      .Replacement.Text = "\1 \2 \3 \4 \5"
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchWildcards = True
      .Execute Replace:=wdReplaceAll
    End With
    If .Sentences.Count > 20 Then
      Do
        With .Paragraphs.Last.Previous.Range
          If .Sentences.Count < 20 Then
            .Characters.Last.Delete
            .InsertAfter " "
          Else
            Exit Do
          End If
        End With
      Loop
    Else
      With .Find
        .Text = "^13"
        .Replacement.Text = " "
      .Execute Replace:=wdReplaceAll
      End With
    End If
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a Macro that Combines Every 5 sentences into a paragraph problem with MS word merging words and sentences aretai Word 5 07-17-2018 12:32 AM
Exceptions for 'Capitalize first letter of sentences' gazpacho Word 1 01-12-2012 11:43 AM
Need a Macro that Combines Every 5 sentences into a paragraph How to filter sentences wth highlighted colour rajpes Word 4 02-25-2011 12:43 AM
Need a Macro that Combines Every 5 sentences into a paragraph keep only sentences beginning with: Wind Michael007 Word VBA 3 01-17-2011 04:11 PM
capitalize first letter of sentences norco1 Word 0 06-25-2006 12:37 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:32 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