Collapsing the Selection

When you no longer want text selected, you can use the Move, MoveEnd, or MoveStart methods to automatically collapse the selection and move the insertion point. Sometimes, however, you might prefer to place the insertion point either at the beginning or the end of the current selection. To so that, use the Collapse method:

Selection.Collapse [Direction]

Direction (optional) Specifies where you want the insertion point to end up.

Use wdCollapseStart to position the cursor at the beginning of the Selection (this is the default). Use wdCollapseEnd to position the cursor at the end of the Selection.

For example, in Listing 7.7 (presented in the previous section), the procedure ends by using the Move method to move the insertion point to the next paragraph. If you prefer to leave the insertion point at the end of the selected paragraph, you need to do two things: extend the selection to the left by one character to remove the paragraph mark from the selection, and then perform the collapse:

.MoveLeft wdCharacter, 1, wdExtend .Collapse wdCollapseEnd

0 0

Post a comment