![]() |
#2
|
||||
|
||||
![]()
Hi Jazz43,
Here's a macro you can use for cleaning up text pasted from the web, emails, pdfs, etc. Aside from acting on the whole document and assuming there are two (or more) paragraph breaks for each real paragraph break, and only one for each line break, there's nothing much you need to know before running it. 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 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] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
vektor | Outlook | 4 | 02-14-2012 02:16 PM |
![]() |
muymalestado | Word | 3 | 09-25-2011 05:06 AM |
![]() |
ahazelwood | Word | 5 | 01-06-2011 02:37 PM |
How would I bulk select and copy highlights and then bulk paste them automatically? | copywriterpro | Word | 0 | 04-19-2010 05:21 AM |
![]() |
P. Alkuin | Word | 2 | 03-15-2010 09:33 AM |