How can I make a shortcut or macro to paste text only format?

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

Guest

When I copy from a web page, and do a regular paste to Word, Word has an
error and closes. I need to use "paste special" as text. I tried to record a
macro to paste as unformated text, but it didn't work. How can I write visual
basic macro to do this?
 
This one has worked for me:

Sub PasteSpecial()

Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False

End Sub

I then assigned it to a keyboard shortcut to call it up easily.

I actually got this by recording it as a macro, but there may have been
something about the web page that interfered with your attempt to do so. You
may want to change or eliminate some of the optional statements (e.g.,
"DisplayAsIcon:"); they came in recording the macro.
 
Actually, all of the optional statements specify default conditions, so you
could just shorten this to:

Sub PasteSpecial()
Selection.PasteSpecial
End Sub
 
The default datatype depends on what's actually in the clipboard at the
time, so you need to specify text if that's what you want the macro to do --

selection.PasteSpecial datatype:=wdPasteText
 
Back
Top