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

向前扩展选定内容,直至遇到另一种颜色的文字为止。Extends the selection forward until text with a different color is encountered.

语法Syntax

expression.expression. SelectCurrentColor

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

示例Example

本示例从文档的开头将所选内容向前扩展,直至遇到另一种颜色的第一个字符,然后显示选定部分中的字符数。This example extends the selection from the beginning of the document to the first character formatted with a different color and then displays the number of characters in the resulting selection.

Selection.HomeKey Unit:=wdStory, Extend:=wdMove 
Selection.SelectCurrentColor 
n = Len(Selection.Text) 
MsgBox "Contiguous characters with the same color: " & n

另请参阅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.