An Unfill Paragraph Macro for MS Word
Here's a Macro that replaces carriage return characters in a selection with nothing. This is useful if you get a chunk of text where someone has ended each line of a paragraph with a carriage return instead of allowing the software to wrap the lines. You can use this macro in MS Word (or anything that reads MS Word macros).
So, if you have a para like this:
one two three
four five six
seven eight nine
and you want it to look like this:
one two three four five six seven eight nine
Instead of manually going through the para and removing the return characters by hand, you can select the paragraph (but not the final return character!) and run the unfill macro below on it.
To put this macro in your copy of Word:
- go to Tools -> Macro -> Macros... and hit Edit.
- You should see either a blank editor (if you have no macros) or the code behind your other macros.
- Put the text below at the end.
- Go to File and save it and then quit and return to word.
- To assign that macro to a key combination, go to Tools -> Customize -> Customize Keyboard.
- In the Categories pane, scroll down to and select Macros.
- Place your cursor in the box for "press new shortcut key" and enter in a key combination that you'll remember and that is (or might be) unique.
- Then hit Assign and then OK.
Here's the macro code:
Sub unfill() ' ' unfill Macro ' Macro recorded 9/4/06 by Joseph Hall ' Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^p" .Replacement.Text = " " .Forward = True .Wrap = wdFindAsk .Format = False .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False End With Selection.Find.Execute Replace:=wdReplaceAll End Sub