Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-04-2011, 02:12 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question How to combine many paragraphs in one paragraph?

How to combine many paragraphs in one paragraph?

please, see the attached images that show my question

In case we need to quote from other's work then in this case we need to copy and paste the whole lines as they are. once they are pasted in word, then each line appears as one paragraph (particularly if they are pasted from pdf file).

How to make these paragraphs in one paragraph AUTOMATICALLY?

regards

Jamal
Attached Images
File Type: jpg Clip_416.jpg (79.2 KB, 26 views)
File Type: jpg Clip_417.jpg (103.2 KB, 22 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #2  
Old 07-04-2011, 02:59 AM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 Jamal,

If you're pasting content with paragraph breaks in it (eg from PDFs & emails), Word can't join them automatically. However, it can be done fairly easily.

Whenever paste text from a PDF, web site or an email, you may end up with a paragraph break at the end of every line within a logical paragraph, and two such breaks between logical paragraphs. You can fix this using a series of wildcard Find/Replace actions, using a macro like:
Code:
Sub CleanUpPastedText()
'Turn Off Screen Updating
Application.ScreenUpdating = False
With ActiveDocument.Range.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  'Eliminate spaces & tabs before paragraph breaks.
  .Text = "[ ^s^t]{1,}^13"
  .Replacement.Text = "^p"
  .Execute Replace:=wdReplaceAll
  'Replace single paragraph breaks with a space
  .Text = "([!^13])([^13])([!^13])"
  .Replacement.Text = "\1 \3"
  'Replace all double spaces with single spaces
  .Execute Replace:=wdReplaceAll
  .Text = "[ ]{2,}"
  .Replacement.Text = " "
  'Delete hypens in hyphenated text formerly split across lines
  .Execute Replace:=wdReplaceAll
  .Text = "([a-z])-[ ]{1,}([a-z])"
  .Replacement.Text = "\1\2"
  .Execute Replace:=wdReplaceAll
  'Limit paragraph breaks to one per 'real' paragraph.
  .Text = "[^13]{1,}"
  .Replacement.Text = "^p"
  .Execute Replace:=wdReplaceAll
End With
'Restore Screen Updating
Application.ScreenUpdating = True
End Sub
Note that the code assumes there are at least two such paragraph breaks between the 'real' paragraphs.

For PC macro installation & usage instructions, see: http://www.gmayor.com/installing_macro.htm
For Mac macro installation & usage instructions, see: http://word.mvps.org/Mac/InstallMacro.html

If you'd prefer to run the macro against just a selected range, change:
ActiveDocument
to:
Selection
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 07-04-2011, 05:03 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

thank you Paul. You have a solution for each single challenge.

But how to make the macro works only on the selected but not in the whole document?

regards

Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #4  
Old 07-04-2011, 07:38 PM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 Jamal,

As advised in my previous reply, change:
ActiveDocument.Content.Find
to
Selection.Find

- and have something selected
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 07-05-2011, 02:37 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Thumbs up

Thanx Paul. Perfect. It did work

regards

Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #6  
Old 07-09-2011, 04:40 PM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

Hi Paul,

How to develop the above macro to include combining also the paragraphs separated by (shift + Enter) or tabs as well as deleting all spaces and punctuation marks?

thank you

regards

Jamal
Attached Images
File Type: jpg Clip_542.jpg (69.6 KB, 20 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #7  
Old 07-11-2011, 05:06 AM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 Jamal,

Shift-Enter creates a manual line break within a paragraph - it does not create a new paragraph. You can delete manual line breaks and tabs by inserting the follwing three lines:
Code:
  .Text = "[^t^l]{1,}"
  .Replacement.Text = " "
  .Execute Replace:=wdReplaceAll
before the line:
.Text = "[ ]{2,}"

Do you really want to delete all spaces and punctuation marks? That would give you text like:
Doyoureallywanttodeleteallspacesandpunctuationmark sThatwouldgiveyoutextlike
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 07-11-2011, 05:47 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

Quote:
Originally Posted by macropod View Post
Hi Jamal,

Shift-Enter creates a manual line break within a paragraph - it does not create a new paragraph. You can delete manual line breaks and tabs by inserting the follwing three lines:
Code:
  .Text = "[^t^l]{1,}"
  .Replacement.Text = " "
  .Execute Replace:=wdReplaceAll
before the line:
.Text = "([ ])[ ]{1,}"

Do you really want to delete all spaces and punctuation marks? That would give you text like:
Doyoureallywanttodeleteallspacesandpunctuationmark sThatwouldgiveyoutextlike

thank you Paul.

You are right. i don't need to delete the spaces! i meant that i needed to delete all other marks except the spaces!

the reason i need this is that:

i save the pdf articles that i read by giving them the title of the article and the name of the author. As you know, as i copy and paste them from pdf file to the Word document, i got them separated in many paragraphs.

Also Windows is very sensitive if we include certain punctuation marks in the name of the file!!!!

this is why i need to combine all paragraph in one paragraph and to get rid of all punctuation marks!!!

i was doing these steps manually before you provide me with the Macro that combines paragraph.

regards

Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #9  
Old 07-12-2011, 02:49 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

Thank you Paul.

the code now doesn't remove the punctuation marks!!!!

what might be the problem?

regards

Jamal
Attached Images
File Type: jpg Clip_570.jpg (107.4 KB, 19 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #10  
Old 07-12-2011, 03:14 AM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 Jamal,

The code I posted in this thread never did remove punctuation marks!
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 07-12-2011, 03:24 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

Quote:
Originally Posted by macropod View Post
Hi Jamal,

The code I posted in this thread never did remove punctuation marks!
Thank you Paul. That's right.

could you please, if your time permits, what should i add to the code to remove the punctuation marks?

regards

Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #12  
Old 07-12-2011, 06:34 AM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 Jamal,

I really don't recommend doing that - it will cause the macro to delete punctation marks in text you're trying to clean up when it's been copied from pdfs, emails, web pages, etc when the punctuation should remain. Still, if that's what you want to do, insert the lines:
Code:
  .Text = "[,.;:‘’'“”""/\!\*\?\\]"
  .Replacement.Text = ""
  .Execute Replace:=wdReplaceAll
after the line:
.MatchWildcards = True
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 07-13-2011, 01:37 AM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows XP How to combine many paragraphs in one paragraph? Office 2007
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Thumbs up

Thank you Paul. it worked like a char. that's what I've been looking for.

regards

Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #14  
Old 03-07-2013, 01:15 PM
Jamal NUMAN Jamal NUMAN is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 64bit
Expert
How to combine many paragraphs in one paragraph?
 
Join Date: Nov 2010
Posts: 525
Jamal NUMAN is on a distinguished road
Question

Hi Paul,

Sorry to bother you again with similar issues.

You have generously provided codes (attached) that:

1. Eliminate particular marks from a selected paragraph
2. Capitalized selected words except prepositions


My intent now is to eliminate spaces and to capitalize all selected words at a time.

For example, the “National spatial plan of zone one” will look like:

NationalSpatialPlanOfZoneOne


Thank you

Best

Jamal
Attached Files
File Type: txt CapitalizeExceptPreposition.txt (1.1 KB, 6 views)
File Type: txt ParagraphCombinationandMarksRemoval.txt (772 Bytes, 6 views)
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank.
Reply With Quote
  #15  
Old 03-07-2013, 02:40 PM
macropod's Avatar
macropod macropod is offline How to combine many paragraphs in one paragraph? Windows 7 64bit How to combine many paragraphs in one paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

The only way you can do that with Find/Replace is to input both the Find and Replace strings you want. A wildcard Find/Replace cannot change the capitalisation of a random string.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to combine many paragraphs in one paragraph? Track chages combine: Stumped! Ulodesk Word 2 01-03-2011 11:43 AM
How to combine many paragraphs in one paragraph? Combine two forms into one lwisniewski Word VBA 3 12-24-2010 03:45 PM
How to combine many paragraphs in one paragraph? Combine pst files? markg2 Outlook 2 04-26-2010 03:09 PM
How do you combine two contact folders? waikoloavrm Outlook 0 04-12-2010 02:31 PM
Bulletizing one paragraph affects all paragraphs GoodWebby Word 0 10-10-2009 12:09 PM

Other Forums: Access Forums

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