moveStart Method
Moves the starting position of an IHTMLTxtRange object. Returns a Long that represents the number of units moved.
expression.moveStart(Unit, Count)
*expression * Required. An expression that returns an IHTMLTxtRange object.
Can be one of the following values
character | Moves one or more characters. |
word | Moves one or more words. A word is a collection of characters terminated by a space or some other white-space character, such as a tab. Punctuation is also included in the word count, so a period at the end of a sentence or a comma in the middle of a sentence would increase the word count by one. |
sentence | Moves one or more sentences. A sentence is a collection of words terminated by a punctuation character, such as a period. |
textedit | Moves to the start or end of the original range. |
Count Optional Long. Specifies the number of units to move. This can be positive (moves the start of the range to the right) or negative (moves the start of the range to the left). The default is 1.
Example
The following example inserts a paragraph into the active document, and then moves the start and end points of the range to change the third and fourth words to a different word.
Sub MoveStartAndEndSelectionPoints()
Dim objRange As IHTMLTxtRange
Dim intStart As Integer
Dim intEnd As Integer
ActiveDocument.body.innerText = "I enjoy writing programs " & _
"with FrontPage VBA."
Set objRange = ActiveDocument.body.createTextRange
objRange.moveStart "word", 2
objRange.moveEnd "word", -4
objRange.Text = "programming "
End Sub
Applies to | IHTMLTxtRange Object