Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2012, 10:03 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 Need a Macro that Combines Every 5 sentences into a paragraph

As stated in the title, I'm looking for a macro that combines every 5 sentences into a paragraph. Each sentence is separated by a paragraph break. For example:



Original article:
This is the first sentence.

This is the second sentence.

This is the third sentence.

This is the fourth sentence.

This is the fifth sentence.

New article:
This is the first sentence. This is the second sentence. This is the third sentence. This is the fourth sentence. This is the fifth sentence.

Help is greatly appreciated. Thanks in advance!
Reply With Quote
  #2  
Old 01-10-2012, 06:11 PM
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,

If your article headings are in one paragraph Style and the text in another, or if there's, say, a double paragraph break between the text and the following article heading and only single paragraph breaks between the text paragraphs, this could all be done quite easily via Find/Replace, without the need for a macro. In any event, we'd need to know how many paragraph breaks exist between the text paragraphs and between them and the article paragraphs.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-11-2012, 08:37 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

I'm curious how you would do this using find/replace?

Also, I've attached an example doc of what I'm working with. There is no header. You'll see the article is broken down by sentence. I need every 5 sentences merged into a paragraph.

Last edited by jgarland; 01-11-2012 at 09:48 AM.
Reply With Quote
  #4  
Old 01-11-2012, 08:48 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,

With the insertion point at the start of the document, try a wildcard Find/Replace, where:
Find = ([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,}^13)
Replace = \1 \2 \3 \4 \5
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-11-2012, 09:02 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

That works like a charm on the example I uploaded, unfortunately it's not working with another file I need to apply this to as well. Do you know a way to join groups of sentences together, i.e. joined together by spintax, to form paragraphs? Attached you'll find another example.

And the reason I was looking for a macro was so I can quickly and easily run the macro and get it done in a couple clicks.
Reply With Quote
  #6  
Old 01-11-2012, 09:10 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,

For the spintax:
Find = ([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,})^13([!^13]{1,})(^13)
Replace = {\1 | \2 | \3 | \4 | \5}\6

Once the specifications are nailed (you didn't tell me about spintax before), this can easily be turned into a macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 01-11-2012, 09: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 tried the updated find/replace on what I sent you and it doesn't seem to be working. Any ideas?
Reply With Quote
  #8  
Old 01-11-2012, 09:20 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,

It works fine for me on the original document (as posted, not after the previous Find/Replace). The second document already appears to be formatted with spintax, so I didn't assume you wanted anything further done to it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 01-11-2012, 09:24 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, I meant I need to apply the merge every 5 groups of sentences within curly brackets to make a paragraph, so I don't have to go through the article and manually merge the sentences groups together to form paragraphs.

Originally when I posted this I had thought that the same method to merge 5 sentences together into a paragraph would also apply to merging the curly bracket sentence groups together, but I was wrong.
Reply With Quote
  #10  
Old 01-11-2012, 09:28 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,

Do the intervening paragraphs have the spintax separators (ie '|')? Can you post a copy of a document showing how these paragraphs look before the merge?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 01-11-2012, 09:30 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

The groups of sentences are separated by a paragraph break. The example2.doc I uploaded in the previous reply is what I'm referring to.
Reply With Quote
  #12  
Old 01-11-2012, 09:33 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,

That document already appears to be formatted the way you want it, so I don't understand the issue.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 01-11-2012, 09:41 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

Attached is what I'm looking to do.

The example shows the original article has 5 groups of sentences (the groups are defined by curly brackets). All I need is a simple way to merge the 5 groups of sentences together to essentially make one paragraph (as shown in the example under "needs to be"), so I don't have to manually go to the end of each group and do a "backspace" to remove the paragraph breaks thus merging the groups together.

So that's why I'm looking for a macro to do this for every 5 groups of sentences.
Attached Files
File Type: docx example 3.docx (12.8 KB, 13 views)
Reply With Quote
  #14  
Old 01-11-2012, 09:47 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,

For that part, all you need is an ordinary Find/Replace, where:
Find = ^p
Replace = space character
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 01-11-2012, 09:51 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

Right, I know about that, but I need it to apply to every 5 groups. Let's say there are 20 groups of sentences in an article; I need to merge every 5 groups together, thus making 4 large groups of paragraphs.
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:20 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