Pasting Clean Text
Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Pasting Clean Text.
I paste a lot of text. (I mean a LOT of text.) When I am copying and pasting text within the same document, it is no problem. When I am copying text from other places, however, pasting that text into a Word document can have strange effects. This isn't a Word problem; it is something about the text I am copying and pasting that causes funky appearance of the text.
To get around this, I normally choose Edit | Paste Special and make sure that the text I am about to paste will be added to the document as unformatted text. Of course, since I paste so much text, continually choosing Edit | Paste Special can be bothersome.
The solution, for me, was to create a very short macro that does the pasting I want—as unformatted text. The following macro, PasteClean, does just that:
Selection.PasteSpecial Link:=False, _
Placement:= wdInLine, _
To make this macro an even more valuable editing tool, I assigned it to a custom tool on the toolbar. Now, when I want to paste a clean copy of what text is in the Clipboard, I simply click the tool and the macro does the rest.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1310) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Pasting Clean Text.
Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!
Leave your own comment:
Comments for this tip:
Richard Ong 09 Mar 2016, 17:23
Thank you so much, Ned. That new command works like a charm. I recorded a new macro and it came up with:
and that wasn't working.
I don't allow automatic updates and recently installed a big backlog of updates. My troubles may have begun then for the reason you suggest.
You've saved me from one of life's persistent niggling irritations!
Ned Zimmerman 08 Mar 2016, 09:30
like you I had a macro that used
for years without issue.
The commenter in the thread you linked to missed the point. The issue isn't that the Clipboard is empty, it's that it contains something that isn't text.
I believe a recent MS security update for Word has changed the PasteSpecial behavior in Word 2007 so that it now throws the runtime error 5342 if the data type of the clipboard contents is not text.
Previously it would just attempt to grab whatever text was in the Clipboard contents and paste that only. My guess is that someone figured out a way to abuse this behavior.
If you record a new macro to paste text unformatted you will now see the following:
This does what you want without throwing the runtime error.
We all just need to update our macros.
Richard Ong 27 Feb 2016, 13:15
A commenter at this site
suggests that that error message is because nothing was copied into the clipboard. The commenter suggested adding this code before the Selection.PasteSpecial command:
On Error Resume Next
This leads to no error message (5342) being displayed when the the macro is run but there is, in fact, text on the clipboard as ctrl-v or Edit->Paste special->Unformatted text both copy something, the first with formatting, the second without.
Richard Ong 27 Feb 2016, 12:48
In Word 2003, I have achieved this "paste unformatted" feat in the past by recording a macro consisting of my going through the menu thus: Edit->Paste special->Unformatted text.
This yields a macro with this code:
This has worked fine for months and months but for some reason it started pasting text WITH formatting. I don't remember doing anything to my settings. I ran "Detect and repair" under Help but that didn't help.
I found your entry here but your suggested code pastes nothing and I get the error window with this message:
"Run-time error '5342':
The specified data type is unavailable."
Ctrl-v pastes SOMETHING but it's formatted, of course.
Charles Morford 14 Jun 2015, 14:04
This may be another of your tips that I can really use. I am writing a book in Word 2003. The 10 chapters of text are complete. I used a pre-formatted template provided by the publisher (CreateSpace). Now I have to complete my work to PDF to submit it to them. I would like to have as clean a copy as possible without loosing the necessary formatting. Will this tip work for me or do you have a better idea? Thank you in advance for your help.
arnold ziffel 01 May 2013, 08:33
Great tip, got something along those lines that I need a macro for. 1)I have a word document that spans a full 80 char wide (only left 50 char used) and thus won't print the first 4 left char. 2) I need to change font type and size. 3) there are a lot of tables and paragragh formatting that I need to get get rid of but keep the text location . I have over 1500+ rtf type documents that I need to "convert" at one shot into a document that has the proper left printable margin. Can you help
Shanker. K.Vee. 21 Aug 2012, 01:11
What about 'Cut, Copy, and Paste' options under 'Advanced' in 'Word Options'? Having a macro instead is anyway better?