Edit GoTo


GoTo Method

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

Selection.GoTo What:=wdGoToItem.wdGoToBookmark 
               Which:=wdGoToDirection.wdGoToPrevious
               Count:=1, _
               Name:="Bookmark_Name"

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, _
               Count:=1

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 
                  Count:=1

objRange.Next Unit:=wdUnits.wdCharacter, _
              Count:=1
objRange.Next Unit:=wdUnits.wdWord, _
              Count:=3
objRange.Next Unit:=wdUnits.wdSentence, _
              Count:=2

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.



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