Navigate to the End of a Word in One Key Stroke

E

e125

Version of Word: 2003. Can someone write a macro that will do the following.
When the cursor is in any part of a word, can it be made to navigate to the
last character of that word. For example: "The squirrels runs up the tree."
As I edit the document after having typed everything, I navigate using the
Ctrl + > and I end up at the word "run" instead of the "s" on squirrels. This
may seem inconsequential to some, but for editing a hundred page document it
can be crucial to saving much time, I would like to be able to navigate to
the end of every word using Alt + > (i.e,. the right navigation key).

Any macros would be much appreciated.
 
G

Graham Mayor

Something like

Sub SelectLastLetter()
Dim oWord As Range
Set oWord = Selection.Words(1)
With oWord
If Right(oWord, 1) = Chr(32) Then
Do Until Right(oWord, 1) <> Chr(32)
.End = .End - 1
Loop
End If
.Start = .End - 1
'.Collapse wdCollapseStart
.Select
End With
End Sub

will select the last letter of the word containing the cursor, ignoring
any punctuation. If you want the cursor BEFORE the last letter, remove the
apostrophe from the start of the line '.Collapse wdCollapseStart.
If you want the cursor AFTER the last letter, change that line to
..Collapse wdCollapseEnd

http://www.gmayor.com/installing_macro.htm


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top