If you know the specific location, then simply make the cursor start there. Everything in Word starts counting from the beginning of the document (0), in character spaces.
The cursor in Word is called the Selection, and it has a range start (and end). These are stored as Long integers.
So if you know the specific location (say 14672) then to make the cursor go there:
Selection.Start = 14672
Most people do not know the specific location as an integer. The issue is - do you know the specific location as a place? And do you just want to go there? Or do you want to select anything on the way. For example:
' just in case the selection is larger than one character
Selection.Collapse Direction:=wdCollapseStart
Selection.Start = ActiveDocument.Paragraphs(3).Start
If the Selection (cursor) is AFTER the start of paragraph 3, everything from the Selection point to the start of paragraph 3 will be selected (highlighted). It will select backwards.
If the selection is BEFORE the start of paragraph 3, then the Selection (cursor) will simply move to the start of paragraph 3.
Do you want to select anything between where you are, and the "specific location"? This is different from just going to that location.
Yachtie's suggestion of using a bookmark is one of the best ways. Although the code is not the way I would do it.
Selection.GoTo What:=wdGoToBookmark, Name:="Text35Orig"
selects the bookmark. No need for Field, or Result.
Here is another example, I always have the following code in my documents. I have this in my ThisDocument module. What it does is simple. Whenever the document closes, it places a bookmark, named "StoppedHere", at the last location of the cursor. Whenever the document opens, it looks for that bookmark, and goes there. It then deletes it, leaving the way for making a new one, when I close the document. This way, I always come back to to where ever I was.
yes, I know Shift-F5 returns to the last location in a document - but it does NOT work on document open.
Code:
Sub Document_Close()
If ActiveDocument.Bookmarks.Exists("StoppedHere") = False Then
ActiveDocument.Bookmarks.Add _
Name:="StoppedHere", Range:=Selection.Range
End If
End Sub
'
Sub Document_Open()
If ActiveDocument.Bookmarks.Exists("StoppedHere") = True Then
Selection.GoTo what:=wdGoToBookmark, Name:="StoppedHere"
ActiveDocument.Bookmarks("StoppedHere").Delete
End If
End Sub
So, what specific location? Oh, BTW: here is a way to find out the specific location of the cursor.
Code:
Sub Here()
Dim X As Long
Selection.Collapse Direction:=wdCollapseStart
X = Selection.Start
Msgbox "Cursor is at character space " & X & _
". Start of document = 0."
End Sub
I bet you will be surprised at the numbers that may come up.
Gerry