Word VBA: Paste Text Only by PasteSpecial Method

The following Word VBA macro pastes plain text.

Macro Example

Sub PasteTextOnly()

  Selection.PasteSpecial DataType:=wdPasteText

End Sub

Description

[Application.]Selection

  Selection...

The Application.Selection property returns the Selection object that represents a selected range or the insertion point.

obj-Word-Application-Selection

The Selection property is a member of the Word.Global class, so we can omit the Application property.

obj-Word-Global-Selection

Selection.PasteSpecial

  Selection.PasteSpecial...

The Selection.PasteSpecial inserts the contents of the Clipboard.

obj-Word-Selection-PasteSpecial

The parameter: DataType specifies a format for the Clipboard contents when they are inserted into the document.

Sub PasteTextOnly()

  Selection.PasteSpecial DataType:=wdPasteText

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-paste-text.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007