Recording macro to PasteSpecial UnformattedText

D

dderolph

I've done this in Word 2003 but can't get a macro to work right in Word 2007.
I want to record a macro to paste text from an external source as unformatted
text. I run the macro recorder and go through the sequence. It works but it
does not work right. It simply pastes, retaining the format from the source
rather than pasting as unformatted text, even though I selected
UnformattedText while recording the macro. Visual Basic editor shows this
code:

Sub PasteText()
'
' PasteText Macro
'
'
Selection.PasteAndFormat (wdPasteDefault)
End Sub

Why is it showing (wdPasteDefault) when I chose UnformattedText when
recording the macro? I'd be glad to fix this via the Visual Basic editor but
I don't know how.
 
L

Lene Fredborg

The macro recorder does not always record exactly what you want. Go to the
Visual Basic editor and replace the line:

Selection.PasteAndFormat (wdPasteDefault)

with this code:

On Error Resume Next
Selection.PasteSpecial DataType:=wdPasteText

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 
D

dderolph

that worked. thanks.

Lene Fredborg said:
The macro recorder does not always record exactly what you want. Go to the
Visual Basic editor and replace the line:

Selection.PasteAndFormat (wdPasteDefault)

with this code:

On Error Resume Next
Selection.PasteSpecial DataType:=wdPasteText

--
Regards
Lene Fredborg - Microsoft MVP (Word)
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
 

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