The information in this article applies to:
SYMPTOMSWhen you use the GoBack method in a Microsoft Visual Basic for Applications macro, or when you press SHIFT+F5, Word may switch to another open document. CAUSE
This behavior occurs because the Visual Basic for Applications GoBack method and the SHIFT+F5 keystroke operate at the Word session level rather than at the Word document level. The Visual Basic for Applications GoBack ethod switches among the last three locations in the currently open documents in which text or formatting has changed. WORKAROUNDMicrosoft provides programming examples for illustration only, without warranty
either expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes that you
are familiar with the programming language being demonstrated and the tools used to
create and debug procedures. Microsoft support professionals 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 needs. If you have limited
programming experience, you may want to contact a Microsoft Certified Solution Provider
or the Microsoft fee-based consulting line at (800) 936-5200. For more information about
Microsoft Certified Solution Providers, please see the following page on the World Wide Web:
http://www.microsoft.com/mcsp/For more information about the support options available from Microsoft, please see the following page on the World Wide Web: http://www.microsoft.com/support/supportnet/overview/overview.aspTo 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.
The following macro returns the insertion point to the bookmark you set.
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:
The following macro returns the insertion point to the range set in the previous example:
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.MORE INFORMATIONThe following is a sample AutoOpen macro that uses the GoBack method: For more information about using the sample code in this article, please
see the following article in the Microsoft Knowledge Base:Q212536 OFF2000: How to Run Sample Code from Knowledge Base Articles REFERENCESFor more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base: Q226118 OFF2000: Programming Resources for Visual Basic for Applications Additional query words: vb vba vbe
Keywords : kbdta kbdtacode wd2000 |
Last Reviewed: July 27, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |