Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 01-11-2012, 09:59 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: 21,962
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,

In that case, try a wildcard Find/Replace where:
Find = (*)^13(*)^13(*)^13(*)^13(*^13)


Replace = \1 \2 \3 \4 \5
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #17  
Old 01-11-2012, 10:06 AM
jgarland jgarland 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 2007
Novice
Need a Macro that Combines Every 5 sentences into a paragraph
 
Join Date: Jan 2012
Posts: 13
jgarland is on a distinguished road
Default

Perfect. Now is there an easy way to make a macro out of this so I can just do an Alt-8 and run it in two clicks?
Reply With Quote
  #18  
Old 01-11-2012, 10:09 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: 21,962
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,

yes, but which of these various Find/Replace operations do you need (and in which order)? More than one can be incorporated into the same macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 01-11-2012, 10:15 AM
jgarland jgarland 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 2007
Novice
Need a Macro that Combines Every 5 sentences into a paragraph
 
Join Date: Jan 2012
Posts: 13
jgarland is on a distinguished road
Default

Just the one you mentioned:

In that case, try a wildcard Find/Replace where:
Find = (*)^13(*)^13(*)^13(*)^13(*^13)
Replace = \1 \2 \3 \4 \5
Reply With Quote
  #20  
Old 01-11-2012, 10:22 AM
jgarland jgarland 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 2007
Novice
Need a Macro that Combines Every 5 sentences into a paragraph
 
Join Date: Jan 2012
Posts: 13
jgarland is on a distinguished road
Default

And actually, is there a way to only apply the macro to all the groups of sentences except the first group? The first group is the title of the article, and the rest of the groups are the article's body.
Reply With Quote
  #21  
Old 01-11-2012, 10:25 AM
jgarland jgarland 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 2007
Novice
Need a Macro that Combines Every 5 sentences into a paragraph
 
Join Date: Jan 2012
Posts: 13
jgarland is on a distinguished road
Default

Sorry, one more thing: can there be a rule that if there is less than 5 groups of sentences (for example at the end of the article, after the initial macro would be run) then merge the remaining sentence groups together?
Reply With Quote
  #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: 21,962
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
  #23  
Old 01-11-2012, 11:19 AM
jgarland jgarland 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 2007
Novice
Need a Macro that Combines Every 5 sentences into a paragraph
 
Join Date: Jan 2012
Posts: 13
jgarland is on a distinguished road
Default

Awesome, it works perfectly. Thank you!!
Reply With Quote
Reply



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:54 AM.


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