Export (0) Print
Expand All
Expand Minimize

Range.PasteSpecial Method

Office 2007
Inserts the contents of the Clipboard. .

Syntax

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

expression   Required. A variable that represents a Range object.

Parameters

NameRequired/OptionalData TypeDescription
IconIndexOptionalVariantIf 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: 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.
LinkOptionalVariantTrue to create a link to the source file of the Clipboard contents. The default value is False.
PlacementOptionalVariantCan be either of the following WdOLEPlacement constants: wdFloatOverText or wdInLine. The default value is wdInLine.
DisplayAsIconOptionalVariantTrue to display the link as an icon. The default value is False.
DataTypeOptionalVariantA format for the Clipboard contents when they're inserted into the document. Can be any WdPasteDataType constant.
IconFileNameOptionalVariantIf DisplayAsIcon is True, this argument is the path and file name for the file in which the icon to be displayed is stored.
IconLabelOptionalVariantIf DisplayAsIcon is True, this argument is the text that appears below the icon.

Example

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

Visual Basic for Applications
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.

Visual Basic for Applications
If Selection.Type = wdSelectionNormal Then
    Selection.Copy
    Documents.Add.Content.PasteSpecial Link:=True, _
        DataType:=wdPasteHyperlink
End If



Community Additions

ADD
Show:
© 2014 Microsoft