SelectCurrentColor Method
Collapse the table of content
Expand the table of content

Selection.SelectCurrentColor Method (Word)

Office 2013 and later

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Extends the selection forward until text with a different color is encountered.

expression .SelectCurrentColor

expression Required. A variable that represents a Selection object.

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 
n = Len(Selection.Text) 
MsgBox "Contiguous characters with the same color: " & n
© 2016 Microsoft