Thursday, July 02, 2009

Paste Unformatted Text into Word

Usually, when I want to copy and paste text into Word from a web page, I don't want the formatting. I just want the text and nothing else. In this entry I discuss various ways I have used to do just that.

Updates.
13/08/2009 9:59:07 AM. Corrected macro text thanks to the very helpful comment by Robert Kszan. Thank you Rob!
10/05/2010 3:46:58 PM. Added my preferred choice - using AutoHotkey!

Use Autohotkey Script

This is an amazing Windows scripting engine that is easy to write for and continually amazes me at the fantastic things it can do. First, install Autohotkey. Then create a plain text script file called utilities.ahk (or anything you want - as long as it has extension ahk) with the following contents.

; http://superuser.com/questions/7271/most-useful-autohotkey-scripts
; Paste as plain text
^+v::
    ClipSaved := ClipboardAll ; Save the entire clipboard to a variable of your choice.
    clipboard = %clipboard%  ; Convert any copied files, HTML, or other formatted text to plain text.
    ClipWait, 2
    Send ^v
    Sleep, 1000
    Clipboard := ClipSaved   ; Restore the original clipboard. Note the use of Clipboard (not ClipboardAll).
    ClipSaved =   ; Free the memory in case the clipboard was very large.
return

Save it and double click it - that's enough for AutoHotkey to pick up the script and have it ready. You should now see the AutoHotkey icon in your system tray. Test it out: copy something from a web-page; paste it into Word to see it pasted with formatting; then use control+shift+v to see it pasted as plain text.

Such an amazing tool, this is my preferred method for doing this now. Forget the rest of my post. :)

If you are as hooked as I am, feel free to try out the other scripts in the Superuser - Most useful AutoHotkey scripts? forum posting I got this one from. I have filled my utilities.ahk with others from that page; and since I want these shortcuts always available, I have put a shortcut to the file in my Startup folder (e.g. C:\Documents and Settings\Robert Bram\Start Menu\Programs\Startup.

Use a Text Editor

One way is to first paste the formatted text into a text editor which ignores the formatting (such as UltraEdit or NotePad) and then re-copy the plain text from the text editor, and paste it into Word.

Use a Firefox Add-On

Alternatively, if I am copying the formatted text from Firefox, I use the Copy Plain Text add-on. I select and right click the text I want and select "Copy as Plain Text". Then I can paste the copied plain text directly into Word.

Use Paste Special

If I have copied the text from another browser (or maybe another Word Document or PDF or something else that copies as formatted text), I can use Word 2007's "Paste Special" function.

Use the paste keyboard shortcut: CTRL+V. This pastes the formatted text, but the "Paste Special" icon appears (a little clipboard icon). Click on this icon and select "Keep Text Only".

Alternatively, access the "Paste Special" dialog through Word's menus.

  1. On the Ribbon's Home Tab, select Paste (select the word "Paste", not the clip-board icon) to bring up the Paste menu.
  2. Select "Paste Special".
  3. In the "Paste Special" dialog, select "As:" "Unformatted Text".
  4. Note there is a keyboard combination of ALT keys you can use to bring up the "Paste Special" dialog: ALT, H (Home tab), V (Paste), S (Paste Special).

Earlier version of Word (that don't have the supposedly super useful Ribbon) have the "Paste Special" dialog under Edit > Paste Special (ALT, E (Edit), S (Paste Special)).

Use a Macro

The Paste Special function is excruciatingly tedious for repeated uses. Luckily, we can make a macro for it and assign a keyboard shortcut to the macro.

Word 2007

  1. On the Ribbon's View tab, select Macros (select the word "Macros", not the icon) to bring up the Macros menu.
  2. Select "View Macros" to bring up the Macros dialog.
    • Or just press Alt+F8 to bring up the Macros dialog!
  3. In "Macro name", enter PasteUnformattedText.
  4. Click Create.
  5. This opens Microsoft Visual Basic and creates a new Sub (Sub Procedure), called PasteUnformattedText. Make sure the Sub Procedure is in Normal > Modules > General. Type the following line into the Sub Procedure.
    Selection.PasteSpecial DataType:=wdPasteText
  6. The code window should look something like this:

    (Click to open larger image.)
  7. Save your work and close Microsoft Visual Basic (ALT+Q).
  8. Back in Word, select Microsoft Office button in the upper left-hand corner.
  9. Select "Word Options".
  10. Select Customize on the left hand side.
  11. Click the Customize button down at the bottom of the "Word Options" dialog to bring up the "Customize Keyboard" dialog.

    (Click to open larger image.)
  12. In the "Customize Keyboard" dialog, select Macros on the left hand side.
  13. Select the macro you just made (PasteUnformattedText) on the right hand side.
  14. Click in "Press new shortcut key" and type the shortcut you want to use. I use "CTRL+SHIFT+V". It says this is currently assigned to something else, but I don't care - I override the old assignment because it isn't something I use.
  15. Click Assign and then Close to exit the "Customize Keyboard" dialog.
  16. Click OK to exit the "Word Options" dialog.
  17. You can now use that shortcut to access your macro.

Word 2003 and earlier

  1. Press Alt+F8 to bring up the Macros dialog.
  2. In "Macro name", enter PasteUnformattedText.
  3. Click Create.
  4. This opens Microsoft Visual Basic and creates a new Sub (Sub Procedure), called PasteUnformattedText. Make sure the Sub Procedure is in Normal > Modules > General. Type the following line into the Sub Procedure.
    Selection.PasteSpecial DataType:=wdPasteText
  5. Save your work and close Microsoft Visual Basic (ALT+Q).
  6. Back in Word, select Tools > Customize to bring up the Customize dialog.
  7. Select the Commands tab.
  8. On the left hand side, select Macros.
  9. On the right hand side, select Normal.NewMacros.PasteUnformattedText (the macro you just created).
  10. Click the Keyboard button down at the bottom of the "Customize" dialog to bring up the "Customize Keyboard" dialog.
  11. Click in "Press new shortcut key" and type the shortcut you want to use. I use "CTRL+SHIFT+V". It says this is currently assigned to something else, but I don't care - I override the old assignment because it isn't something I use.
  12. Click Assign and then Close to exit the "Customize Keyboard" dialog.
  13. Click OK to exit the "Word Options" dialog.
  14. You can now use that shortcut to access your macro.

Other Links

Other pages that helped me make this entry.