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 data as an icon. 默认值为 FalseThe default value is False.
IconFileNameIconFileName 可选Optional VariantVariant 如果 DisplayAsIconTrue,则指定包含所用图标的文件名。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.



仅当_Format_ = "HTML" 时, 才会出现_NoHTMLFormatting_问题。在所有其他情况下, _NoHTMLFormatting_将被忽略。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.

对于除英语之外的其他语言的开发人员, 您可以使用下列常量之一 (0-5) 与图片文件格式的等效字符串相对应。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"


此示例将剪贴板中的 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,

支持和反馈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.