Chapter 14. The Range and Selection Objects
In this chapter:
Comparing the Range and Selection Objects
Range and Selection Variables
Creating a Range or Selection Object
Changing a Range Object
Range and Selection Object Properties and Methods
The Range and Selection objects are the workhorses of the Word object model, as you can probably tell by the relative length of this chapter. One of the reasons that the Range object is so important is that it often provides the gateway to many “properties” of an object. Put more plainly, in many cases what you might expect to be a property of an object is in fact a property of the object’s child Range object. For instance, to access the text in the first paragraph in the active document, use:
which just produces the error “Method or data member not found” because Text is a property of the Range object, not of the Paragraph object.
Simply put, the Range and Selection objects both represent a contiguous area with in a Word document. However, it is important to keep in mind that they represent more than just the text within this area. For instance, a Range object has no less than 65 properties, only one of which is the Text property.
In the next two lists, members marked with an R are unique to the Range object, and those marked with an S are unique to the Selection object. All remaining members with neither an R nor an S are common to both objects. The items ...