Friday, February 24, 2012

Paste Without Formatting in Word 2007

I don't know about you, but when I'm pasting something into a Word document (like from a web page), I find that more often than not, I want it to go in without any formatting. If you do this once or twice in a day, its easy enough to click on the "Paste" control, change the selection in the popup window to "Unformatted Text", and press ok. However, if you have to do this more frequently, this can quickly become a pain.

Today, I was working on a document where I was copying titles from our software bug tracking system over to a table in a word document. Because I was coming from an HTML document, Word was happily keeping the HTML format, and putting the titles in with a large blue-colored font. This is not what I wanted! Since I had to do this for 50 or so entries, I quickly got tired of the solution above, and went to Google and found this nice article:

  Paste text without the formatting into a Word document

Nice!  However, I quickly realized that my version of Word (2007) didn't mesh too well with the article's target version (2002).  If you've used the newer version, you'll know what I'm talking about.  Sure, the ribbon UI looks nice, but WHERE THE HELL DID EVERYTHING GO!  I remember how long it took me just to figure out how to PRINT my document for the first time!  Sheesh.

Well, time heals all wounds, and I've gotten much more adept at the latest Word layout, and even figured out how to apply the instructions from the article to my version.  In case you were interested (and so I don't forget how to do this), I'm reproducing the Word 2007-friendly instructions here:

STEP 1 - Create the Macro

  • Start Word 2007
  • On the View tab, click the Macros button
  • In the Macro name box, type PasteUnformattedText
  • Make sure that "All active templates and documents" is displayed in the "Macros in:" dropdown, and then click the Create button.
  • The Microsoft Visual Basic editor will open
  • Directly above the End Sub statement in the PasteUnformattedText subroutine, type or copy/paste the following line of code:
Selection.PasteSpecial DataType:=wdPasteText
  • On the file menu, select "Close and Return to Microsoft Word"

STEP 2 - Assign the Macro to CTRL-V

  • Open the main Word menu by clicking on the Microsoft Office icon in the upper-left corner (round button)
  • At the bottom of the popup window (not one of the menu choices), click the "Word Options" button.
  • Select "Customize" from the left panel.
  • Near the bottom of the panel, click on the "Customize..." button next to "Keyboard shortcuts:"
  • Make sure the "Save changes in:" dropdown shows "Normal.dotm"
  • In the Categories list, click Macros
  • In the Macros list, click PastUnformattedText
  • Click in the "Press new shortcut key" box (the cursor will appear there)
  • Press and hold the CTRL key, and then press "V".  You should now see "CTRL-V" in the box.
  • Click the "Assign" button, and then "Close", and then "Ok"
That's it!  Now anytime you copy (CTRL-C) from a web page, and then paste (CTRL-V) into your word document, you will get the unformatted text without any extra work.  If you decide you want the original default behavior back, switching is simple:

Restore Default Behavior to CTRL-V

  • Open the main Word menu by clicking on the Microsoft Office icon in the upper-left corner (round button)
  • At the bottom of the popup window (not one of the menu choices), click the "Word Options" button.
  • Select "Customize" from the left panel.
  • Near the bottom of the panel, click on the "Customize..." button next to "Keyboard shortcuts:"
  • Make sure the "Save changes in:" dropdown shows "Normal.dotm"
  • In the Categories list, click Macros
  • In the Macros list, click PastUnformattedText
  • In the "Current Keys" box, click on CTRL-V.
  • Click the "Remove" button, and then "Close", and then "Ok"
Back to normal!  Of course, that macro is still there if you ever want to use it again, so you never have to repeat STEP 1 above.

Well, back to work.

2 comments:

Don Snabulus said...

That is a good one. I will need to check how hard it is to convert to Office for Mac 2011. Up until now, I have just kept NotePad++ (PC) or TextMate (Mac) open and did a Ctrl-V, Ctrl-A, Ctrl-C in the text editor, then Ctrl-V in Word.

Your method would be a lot quicker.

DewKid said...

Heh, I LOVE Notepad++, along with Gimp, and WinMerge, it's one of my required installs on any new desktop.

Should be easy to convert for Mac 2011. The VB code should be identical: you'll just need to find where Mac hides the keyboard mappings.