Recording macro to PasteSpecial UnformattedText

  • Thread starter Thread starter dderolph
  • Start date Start date
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.
 
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
 
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
 
Back
Top