Paste Text Only

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a simple way to assign a keyboard function to paste text only?

The usual method Edit/Paste Special/Unformatted text, is cumbersome when you
have to do a lot of it.

I tried to wirte a macro to do it, but it either works for a few times and
quits, or simply does not work at all.

I am editing multiple documents and do not want to keep importing all of the
formatting from other documents when I cut and paste.

There has to be some way to do this easily
 
Macros don't wear out. They can't 'quit' after a few times. They may well
have errors in the code, so they don't always work; or (a common problem
with macros created using the recorder) they may make assumptions about the
context in which they are used, and fail if used in other contexts.

In this case, there is potentially an issue if you try to paste special as
text and the clipboard holds something that cannot be pasted as text (eg a
picture).

Why not post your macro code to the word.vba forum? The problem is eminently
solvable.
 
I created the macro using the recorder as follows:
I copied a line of text to the clipboard
Started the recorder
Went to edit/paste special/unformatted text
Stopped the recorder

This is the code from that macro:
Sub Paste_Text()
'
' Paste_Text Macro
' Macro recorded 10/27/2006 by John Gregory
'
Selection.PasteAndFormat (wdPasteDefault)
End Sub

Is it wrong? If so, how come the steps I performed did not result in a
useable macro?

Thank you for your help.
 
Hi John,

Yes, it's wrong, because the macro recorder has more bugs than a
picnic lunch. Try this instead:

Sub Paste_Text()
On Error Resume Next
Selection.PasteSpecial DataType:=wdPasteText
End Sub

Because of the On Error statement, if the clipboard's contents can't
be interpreted as text, the macro will simply do nothing. Otherwise it
will paste unformatted text.

For more on fixing broken recorder macros, see
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
Yes,

That worked! Thank you very much.

Jay Freedman said:
Hi John,

Yes, it's wrong, because the macro recorder has more bugs than a
picnic lunch. Try this instead:

Sub Paste_Text()
On Error Resume Next
Selection.PasteSpecial DataType:=wdPasteText
End Sub

Because of the On Error statement, if the clipboard's contents can't
be interpreted as text, the macro will simply do nothing. Otherwise it
will paste unformatted text.

For more on fixing broken recorder macros, see
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top