Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2007 Word Macro to Paste Special Unformatted Text 1

Status
Not open for further replies.

judgehopkins

Technical User
Mar 23, 2003
780
US
Code:
Sub PasteSpecialUnformatted()
'
' PasteSpecialUnformatted Macro
'
'
    Selection.Collapse Direction:=wdCollapseStart
    Selection.PasteSpecial DataType:=wdPasteText
End Sub

Code:
Sub test()
'
' test Macro
'
'
    Selection.PasteAndFormat (wdPasteDefault)
End Sub

I got the first macro from Word's help files.

When I select text to replace and run the macro, it correctly inserts the contents of the clipboard but does not replace the selected text.

I got the second macro by recording the keystrokes for paste special/unformatted text.

When I select text to replace and run the macro, it correctly inserts the contents of the clipboard and does replace the selected text, but it is not unformatted text.


What am I doing wrong?

Thanks!

There are two guaranteed rules of success: First, never tell everything you know.
 
I use

Code:
Public Sub PasteUnformatted()
  Selection.PasteSpecial Link:=False, _
      DataType:=wdPasteText, _
      Placement:=wdInLine, DisplayAsIcon:=False
End Sub

Courtesy of fumei in thread68-1451704

Your first snippet doesn't do what you want because it collapses the selection - that is, it puts the cursor at the beginning of the selection.
 
Perfect!

Thank you ... I am rummaging about, looking for my favorite mint julep bucket ... er, glass.

There are two guaranteed rules of success: First, never tell everything you know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top