Loading
Word.Tips.Net WordTips (Menu Interface)

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:

Sub PasteClean()
    Selection.PasteSpecial Link:=False, _
      DataType:=wdPasteText, _
      Placement:= wdInLine, _
      DisplayAsIcon:=False
End Sub

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.

Related Tips:

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

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:

Selection.PasteAndFormat (wdPasteDefault)

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
Richard,
like you I had a macro that used
Selection.PasteSpecial DataType:=wdPasteText

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:

Selection.PasteAndFormat wdFormatPlainText

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
PS:

A commenter at this site

http://answers.microsoft.com/en-us/office/forum/office_2007-customize/macro-for-word-2007-paste-special-gives-an-error/e7624781-d131-4629-832f-a59c9779fb6a?db=5&auth=1

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:

Selection.PasteSpecial DataType:=wdPasteText

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
Hey Allen,

What about 'Cut, Copy, and Paste' options under 'Advanced' in 'Word Options'? Having a macro instead is anyway better?
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.