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

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?
 
G

Guest

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.
 
G

Guest

Actually, all of the optional statements specify default conditions, so you
could just shorten this to:

Sub PasteSpecial()
Selection.PasteSpecial
End Sub
 
J

Jezebel

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
 

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

Top