1 min read

Categories

42763897005_59ee30b8c0

My preference for reading books is ebooks over printed books. One thing I like about eBooks is the ability to copy and paste chunks of text into Word documents, that I use to summarize the books for better retention. Often times the text contains arbitrary spaces inbetween words, hyphenation, and or word wraps after being pasted into word, though.:

cleanupWordBefore

In this post I would like to share a small Word Macro I use in order to “cleanup” text after it’s being pasted into a Word document from an eBook. Running the macro should turn the example text into this:

cleanupWordAfter.

The macro is just using the VBA built-in Find method in order to perform multiple successive search and replace actions against a selected text. utili

  1. Insert a marker at the end of the selected text “®®”.

  2. Replace the paragraph mark “^p” with a space.

  3. Utilize a regular expression in order to replace multiple spaces between words with one.

  4. Remove hyphenation.

  5. Replace the end marker with a paragraph mark.

  6. Remove spaces that precede a period.

  7. Remove formatting by applying the “Normal” style to the selected text

You can follow the instructions from this youtube video to add the macro to your global word template (normal.dotm) in order to make it available for all your Word document and those over here to add a button to Word’s quick access bar that launches the Macro.

Here is the code: https://gist.github.com/DBremen/36d2816fff59537486dd1c292a707580

shareThoughts


Photo Credit: hans-johnson Flickr via Compfight cc