WORKAROUND
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this problem and return to the previous editing location within a document, use one of the following methods.
Method 1: Set a permanent bookmark.
When you run the macro, the insertion point goes to this bookmark
location.
The following macro creates a bookmark called "mark" at the insertion
point.
NOTE: If the document that contains the bookmark is not open, you receive an error message.
Sub SetBookMark()
On Error Resume Next
Selection.Bookmarks.Add Name:="mark"
If Err >0 Then MsgBox Err.Description
End Sub
The following macro returns the insertion point to the bookmark you set.
Sub GoToMark()
On Error Resume Next
Selection.GoTo What:=wdGoToBookmark, Name:="mark"
If Err > 0 Then MsgBox Err.Description
End Sub
For more information about adding bookmarks, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the
Help menu, type
Add Bookmark in the Office Assistant or the Answer Wizard, and then click
Search to view the topic.
Method 2: Set a named range.
The named range exists only while the macro is running. You can return to the named location from within any document while the document that contains the named range is open.
NOTE: If the document that contains the named range is not open, you receive an error message.
The following macro defines a range called "MyRange" at the insertion point:
Sub SetRangeMark()
On Error Resume Next
Set MyRange = Selection.Range
If Err > 0 Then MsgBox Err.Description
End Sub
The following macro returns the insertion point to the range set in the previous example:
Sub GoToRangeMark()
On Error Resume Next
MyRange.Select
If Err > 0 Then MsgBox Err.Description
End Sub
For more information about the Range method, in the Visual Basic Editor, click
Microsoft Visual Basic Help on the
Help menu, type
Range method in the Office Assistant or the Answer Wizard, and then click
Search to view the topic.