The Selection Object

The Selection object represents text that is selected (highlighted) in a document. A Selection object is always present, even if no text is selected. The Selection object can be accessed from the Application, Window, and Pane objects, but not the Document object. This may seem strange, but it works this way because the Selection object is related to text that is highlighted on the screen. However, since this is a global object (as described in Chapter 4) you can access it directly within Word.

You can determine the type of the current selection with the Selection object's Type property. This property can have various values, all identified by defined global constants (which you can view in the Object Browser as described ...

Get Office® XP Development with VBA now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.