Worksheet.PasteSpecial method (Excel)

Pastes the contents of the Clipboard onto the sheet, using a specified format. Use this method to paste data from other applications or to paste data in a specific format.

Syntax

expression.PasteSpecial (Format, Link, DisplayAsIcon, IconFileName, IconIndex, IconLabel, NoHTMLFormatting)

expression A variable that represents a Worksheet object.

Parameters

Name Required/Optional Data type Description
Format Optional Variant A string that specifies the Clipboard format of the data.
Link Optional Variant True to establish a link to the source of the pasted data. If the source data isn't suitable for linking or the source application doesn't support linking, this parameter is ignored. The default value is False.
DisplayAsIcon Optional Variant True to display the pasted data as an icon. The default value is False.
IconFileName Optional Variant The name of the file that contains the icon to use if DisplayAsIcon is True.
IconIndex Optional Variant The index number of the icon within the icon file.
IconLabel Optional Variant The text label of the icon.
NoHTMLFormatting Optional Variant True to remove all formatting, hyperlinks, and images from HTML. False to paste HTML as is. The default value is False.

Remarks

Note

NoHTMLFormatting only matters when Format = "HTML"; in all other cases, NoHTMLFormatting is ignored.

You must select the destination range before you use this method.

This method may modify the sheet selection, depending on the contents of the Clipboard.

For developers of languages other than English, you can substitute one of the following constants (0-5) to correspond with the string equivalent of the picture file format.

Format argument String equivalent
0 "Picture (PNG)"
1 "Picture (JPEG)"
2 "Picture (GIF)"
3 "Picture (Enhanced Metafile)"
4 "Bitmap"
5 "Microsoft Office Drawing Object"

Example

This example pastes a Microsoft Word document object from the Clipboard to cell D1 on Sheet1.

Worksheets("Sheet1").Range("D1").Select 
ActiveSheet.PasteSpecial format:= _ 
 "Microsoft Word 8.0 Document Object"

This example pastes a picture object and does not display it as an icon.

Worksheets("Sheet1").Range("F5").PasteSpecial _ 
 Format:="Picture (Enhanced Metafile)", Link:=False,
 DisplayAsIcon:=False 

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.