PasteSpecial 方法 (Excel)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.


表达式PasteSpecial(FormatLinkDisplayAsIconIconFileNameIconIndexIconLabelNoHTMLFormatting)expression.PasteSpecial (Format, Link, DisplayAsIcon, IconFileName, IconIndex, IconLabel, NoHTMLFormatting)

_表达式_一个代表**工作表** 对象的变量。expression A variable that represents a Worksheet object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
FormatFormat 可选Optional VariantVariant 指定数据的剪贴板格式的字符串。A string that specifies the Clipboard format of the data.
LinkLink 可选Optional VariantVariant 如果为 True,则建立指向粘贴数据来源的链接。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. 默认值为 FalseThe default value is False.
DisplayAsIconDisplayAsIcon 可选Optional VariantVariant 如果为 True,则将粘贴内容显示为图标。True to display the pasted as an icon. 默认值为 FalseThe default value is False.
IconFileNameIconFileName 可选Optional VariantVariant 如果_DisplayAsIcon_为True, 则为包含要使用的图标的文件的名称。The name of the file that contains the icon to use if DisplayAsIcon is True.
IconIndexIconIndex 可选Optional VariantVariant 图标文件内的图标索引号。The index number of the icon within the icon file.
IconLabelIconLabel 可选Optional VariantVariant 图标的文本标签。The text label of the icon.
NoHTMLFormattingNoHTMLFormatting 可选Optional VariantVariant 如果为 True,则从 HTML 中删除所有的格式设置、超链接和图像。True to remove all formatting, hyperlinks, and images from HTML. 如果为 False,则完整粘贴 HTML。False to paste HTML as is. 默认值为 FalseThe default value is False.


注释 NoHTMLFormatting_在_Format = ?HTML? 时仅有考虑。Note NoHTMLFormatting will only matter when Format = ?HTML?. 在所有其他情况下, _NoHTMLFormatting_将被忽略。In all other cases, NoHTMLFormatting will be 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.


此示例将剪贴板中的 Microsoft Word 文档对象粘贴到工作表 Sheet1 上的单元格 D1 中。This example pastes a Microsoft Word document object from the Clipboard to cell D1 on Sheet1.

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,

注释 对于除英语之外的其他语言的开发人员, 您可以使用以下常量之一 (0-5) 与图片文件格式的等效字符串相对应:Note 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 参数Format Argument 等效字符串String Equivalent
00 "图片 (PNG)""Picture (PNG)"
11 "图片 (JPEG)""Picture (JPEG)"
双面2 "图片 (GIF)""Picture (GIF)"
第三章3 "图片 (增强型图元文件)""Picture (Enhanced Metafile)"
44 "Bitmap"
55 "Microsoft Office 图形对象""Microsoft Office Drawing Object"

另请参阅See also

Worksheet 对象Worksheet Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.