#1
|
|||
|
|||
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
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#2
|
||||
|
||||
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 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] |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Thanx Paul. Perfect. It did work
regards Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#6
|
|||
|
|||
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
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#7
|
||||
|
||||
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 .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] |
#8
|
|||
|
|||
Quote:
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. |
#9
|
|||
|
|||
Thank you Paul.
the code now doesn't remove the punctuation marks!!!! what might be the problem? regards Jamal
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#10
|
||||
|
||||
Hi Jamal,
The code I posted in this thread never did remove punctuation marks!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Quote:
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. |
#12
|
||||
|
||||
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 .MatchWildcards = True
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
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. |
#14
|
|||
|
|||
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
__________________
Jamal NUMAN, Jamal432@gmail.com, P.O.BoX: 731, Ramallah, West Bank. |
#15
|
||||
|
||||
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] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Track chages combine: Stumped! | Ulodesk | Word | 2 | 01-03-2011 11:43 AM |
Combine two forms into one | lwisniewski | Word VBA | 3 | 12-24-2010 03:45 PM |
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 |