CopyFormat 方法 (Word)Selection.CopyFormat method (Word)

复制选定文字第一个字符的字符格式。Copies the character formatting of the first character in the selected text.

语法Syntax

expression.expression. CopyFormat

_表达式_是必需的。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.

备注Remarks

如果选定了一个段落标记,则 Word 除了复制字符格式,还复制段落格式。If a paragraph mark is selected, Word copies paragraph formatting in addition to character formatting. 您可以使用**PasteFormat** 方法将复制的格式应用于另一个选定内容。You can apply the copied formatting to another selection by using the PasteFormat method.

示例Example

本示例将活动文档第一段的格式复制到第二段。This example copies the formatting of the first paragraph to the second paragraph in the active document.

ActiveDocument.Paragraphs(1).Range.Select 
Selection.CopyFormat 
ActiveDocument.Paragraphs(2).Range.Select 
Selection.PasteFormat

本示例折叠选定内容,并将选定内容的字符格式复制到下一个单词。This example collapses the selection and copies its character formatting to the next word.

With Selection 
 .Collapse Direction:=wdCollapseStart 
 .CopyFormat 
 .Next(Unit:=wdWord, Count:=1).Select 
 .PasteFormat 
End With

另请参阅See also

Selection 对象Selection 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.