Paste Special Macro

H

hfrupn

I have recorded a macro and assigned it to a button. The macro was recorded
by selecting Edit\Paste Special then select un-formatted text and then OK.
This is the result when you go to edit macro;
Sub PasteSpecial()
Selection.PasteAndFormat (wdPasteDefault)
End Sub
The problem is it pastes all, not just the text.

Can anyone tell me how to set up this macro?

Regards
Nick

PS. I’m using Word 2003
 
G

Graham Mayor

The macro recorder does not always do the trick. In this case you need

Sub PasteUnfText()
On Error GoTo oops
Selection.PasteSpecial _
DataType:=wdPasteText, _
Placement:=wdInLine
End
oops:
Beep
End Sub

The error trapping if to prevent the crash that occurs if you have nothing
selected when you run the macro.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
H

hfrupn

Thanks Graham, worked a treat

Graham Mayor said:
The macro recorder does not always do the trick. In this case you need

Sub PasteUnfText()
On Error GoTo oops
Selection.PasteSpecial _
DataType:=wdPasteText, _
Placement:=wdInLine
End
oops:
Beep
End Sub

The error trapping if to prevent the crash that occurs if you have nothing
selected when you run the macro.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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