An ode to Word macros

Last week, John C Dvorak wrote about technical duds. And it’s unfortunate about what happened to Word macros, because at times they can be extremely useful, and not terribly difficult to use, either.

Here’s my favorite macro–a method to join single lines. You’ll wonder why it never became a standard feature in Word. You won’t use it often, but when you need it, you need it badly.

This works in Word 2003, and worked very similarly (possibly identically) in earlier versions of Word too. Perhaps going back to Word for Windows 6.0 from the Windows 3.1 days. The functionality is buried in Word 2007, so I’ll have to revisit that another time.

It’s extremely useful for removing extraneous line breaks from stuff you copy and paste into Word from e-mail messages, web pages, Acrobat documents, and anything else you didn’t create yourself originally. Removing those breaks allows you to reformat it to fit your document neatly. I only need this a few times a year, but when I need it, this macro can sometimes save me hours of tedious work.

Go to Tools, Macro, and select Record New Macro. Type join_single_lines as the name and click OK. Now hit ctrl-H to bring up Find/Replace. In the Find What field, type ^p^p. In the Replace field, type &&&&. Click Replace All. Now change the Find What field to ^p and blank out the Replace field. Click Replace All. Now change the Find What field to &&&&, the Replace field to ^p^p, and click Replace All yet again.

Then click the little stop button on your macro recorder.

Now any time you need to remove those line breaks, go to Tools, Macro, Macros, select join_single_lines, and click Run.

You can do some other nifty tricks too, like recording a macro that searches for a period followed by two spaces and replaces it with a period followed by a single space. Or searching for a carriage return followed by a tab character (^p^t) and replacing it with two carriage returns (^p^p). Or you can record a macro that does the opposite, if you prefer traditional indentations.

These macros are extremely simple and don’t even use 1% of the functionality of Word’s macro language, but that’s OK. They’re useful and require no programming skill to implement. You just have to remember that they’re there when you need them.

2 thoughts on “An ode to Word macros

  • January 31, 2012 at 9:49 am
    Permalink

    Notepad++ (http://notepad-plus-plus.org/) is your friend. I use it to do text processing before passing along files to their next destinations (whether going into Word or being uploaded as a data file). In Notepad++, you load the document, hit Control-F to find, pick the Replace tab, make sure the Search Mode radio button has Extended selected, then do a find on \r\n\r\n, replacing it with \r\n, and hit Replace All. \r is a carriage return, \n is a new line (AKA and ). There may be an easier way to do this, and there may be a way to record it within Notepad++ as a macro, but this works for me. Once your text is in the shape you want it, pass it to the next step. Notepad++ handles large files with ease and speed. Plus, it’s free.

  • January 31, 2012 at 9:51 am
    Permalink

    My AKA contents got stripped out. CR and LF, only I had encased them in opening and closing brackets.

Comments are closed.

%d bloggers like this:
WordPress Appliance - Powered by TurnKey Linux