PasteSpecial Method

Inserts the contents of the Clipboard. Unlike with the Paste method, with PasteSpecial you can control the format of the pasted information and (optionally) establish a link to the source file (for example, a Microsoft Excel worksheet).

Note  If you don't want to replace the contents of the specified range or selection, use the Collapse method before you use this method. When you use this method, the range or selection doesn't expand to include the contents of the Clipboard.

expression.PasteSpecial(IconIndex, Link, Placement, DisplayAsIcon, DataType, IconFileName, IconLabel)

expression Required. An expression that returns one of the objects in the Applies To list.

IconIndex   Optional Variant. If DisplayAsIcon is True, this argument is a number that corresponds to the icon you want to use in the program file specified by IconFilename. Icons appear in the Change Icon dialog box (Insert menu, Object command, Create New tab): 0 (zero) corresponds to the first icon, 1 corresponds to the second icon, and so on. If this argument is omitted, the first (default) icon is used.

Link   Optional Variant. True to create a link to the source file of the Clipboard contents. The default value is False.

Placement   Optional Variant. Can be either of the following WdOLEPlacement constants: wdFloatOverText or wdInLine. The default value is wdInLine.

DisplayAsIcon   Optional Variant.Optional Variant. True to display the link as an icon. The default value is False.


Can be one of the following WdPasteDataType constants
The default format varies, depending on the contents of the Clipboard.

IconFileName   Optional Variant.If DisplayAsIcon is True, this argument is the path and file name for the file in which the icon to be displayed is stored.

IconLabel   Optional Variant.If DisplayAsIcon is True, this argument is the text that appears below the icon.


This example inserts the Clipboard contents at the insertion point as unformatted text.

Selection.Collapse Direction:=wdCollapseStart
Selection.Range.PasteSpecial DataType:=wdPasteText

This example copies the selected text and pastes it into a new document as a hyperlink. The source document must first be saved for this example to work.

If Selection.Type = wdSelectionNormal Then
    Documents.Add.Content.PasteSpecial Link:=True, _
End If

Applies to | Range Object | Selection Object

See Also | Copy Method | Cut Method | Paste Method