Edit GoTo

GoTo Method

The Document, Range and Selection objects all have a GoTo method

Selection.GoTo What:=wdGoToItem.wdGoToBookmark 
               Count:=1, _

If the What parameter is wdGoToBookmark, wdGoToComment, wdGoToField or wdGoToObject then the Name parameter specifies a name.

This will move to beginning of the line

Selection.GoTo What:=wdGoToItem.wdGoToLine, _ 
               Which:=wdGoToDirectionwdGoToAbsolute, _

To select the line you can use the Expand method

Selection.Expand wdUnits.wdLine 

Next and Previous Methods

Note there is no wdGoToCharacter, wdGoToWord or wdGoToSentence constants.
To do this you can use the Next and Previous methods.
This methods applies to a Range, Selection and a Paragraph

objSelection.Next Unit:=wdUnits.wdWord 

objRange.Next Unit:=wdUnits.wdCharacter, _
objRange.Next Unit:=wdUnits.wdWord, _
objRange.Next Unit:=wdUnits.wdSentence, _

objParagraph.Next Unit:=wdUnits.wdCharacter

GoToNext and GoToPrevious Methods

The GoToNext and GoToPrevious methods are similar to the GoTo with the Which parameter set to wdGoToNext or wdGoToPrevious and the Count set to 1.
These methods apply to a Range and a Selection

objRange.GoToNext What:=wdGoToItem.wdGoToBookmark 
objSelection.GoToPrevious What:=wdGoToItem.wdGoToBookmark

InRange Method

There is also an InRange method which reports whether one range is contained within another.

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext