Word 2013 Move the insertion point to the end of a word

206 views Asked by At

It there a simple direct way to move the insertion point to the end of a word in Word 2013? By end of the word, I mean the last character of the word is to the insertion point’s left, and the trailing space or punctuation is to the right, and nothing is selected. I’m convinced Word 2002 was able to do this without a macro. I’ve created the following macro to do this, but I’m convinced there has to be a built in way to do it, or at least the macro can be made simpler.

Sub MoveCursorEndWord()
Selection.MoveRight Unit:=wdWord, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=1

If Selection.Text <> " " Then
Selection.MoveRight Unit:=wdCharacter, Count:=1
End If

End Sub
1

There are 1 answers

0
Variatus On

Actually, the procedure I came up with isn't so much different from yours at all.

Sub EndOfWord()

    Dim Rng As Range

    With Selection
        .Words(1).Select
        .Collapse wdCollapseEnd
        Do While .Start
            Set Rng = .Range
            Rng.MoveStart wdCharacter, -1
            If Asc(Rng.Text) = 32 Then
                .Move wdCharacter, -1
            Else
                Exit Do
            End If
        Loop
    End With
End Sub

The problem is that Word insists on including trailing spaces into its concept of a "word". Since you seem to follow a different definition there is a natural conflict.