Moving the Insertion Point

The insertion point is the simplest form of the Selection object. If your code needs to move the insertion point, the easiest way to do this is to use the Move method, which collapses the current selection and moves the insertion point by a specified number of units. You can also use the MoveEnd method to move the insertion point to the end of the specified unit (such as a paragraph), or the MoveStart method to move the insertion point to the beginning of the specified unit. (Note that all three methods return the number of units that the insertion point was moved.) The syntax is the same for each method:

Selection.Move([Unit][, Count]) Selection.MoveEnd([Unit][, Count]) Selection.MoveStart([Unit][, Count])

Unit (optional) Specifies the unit by which the insertion point is moved.

For regular text, use wdCharacter (this is the default), wdWord, wdLine, wdSentence, wdParagraph, wdSection, or wdStory. In a table, use wdCell, wdColumn, wdRow, or wdTable. Count (optional) The number of units by which the insertion point is moved

For example, you probably know that Word offers many keyboard shortcuts for navigating characters, words, paragraphs, screens, and so on. You can press Ctrl+left arrow or Ctrl+right arrow to move word by word, Ctrl+up arrow and Ctrl+down arrow to move paragraph by paragraph, and so on. However, Word does not have a keyboard shortcut for moving from one sentence to another, which is sorely missed. To implement this useful shortcut yourself, use the macros in Listing 7.6 to navigate forward and backward one sentence.

0 0

Post a comment