#1
|
|||
|
|||
Macro for fixing abnormally formatted paragraph line breaks
Hey all,
I was wondering if someone can help me with an issue. I have been using a Macro to format incorrectly formatted line breaks. For example: Hey my name is Jarjarb52 to Hey my name is Jarjarb52 However, I was wondering if this Macro can be changed in a couple ways: 1) If there is a capital letter, a quote sign ("), or a number (1,2,3,etc), then it should not remove the line break 2) If there is a double line break, it should not get rid of it. Ex: "Hey my name is Jarjarb52. Today is a sunny day" In this case, it should leave it as is. Can anyone tell me how to edit the following macro to do these two things? Code:
Sub CleanUpPastedText() Application.ScreenUpdating = False With Selection.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 |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issue with line breaks and paragraph breaks in bullet point document | philiphunter7 | Word | 8 | 05-10-2020 11:51 PM |
Need ca macro to remplace all line breaks inside all cells | Chibiberu | Excel Programming | 4 | 03-30-2019 10:56 AM |
Cross-post: fixing equations in one line | mohsen.amiri | Word | 0 | 01-30-2017 10:52 AM |
Replace paragraph-marks (line-breaks) in tables with a character-string | Aztec | Word VBA | 2 | 04-02-2013 10:52 PM |
Paragraph line breaks | muymalestado | Word | 3 | 09-25-2011 05:06 AM |