WD98: On Exit Macro Jump to Unprotected Section Fails

ID: Q183308

The information in this article applies to:

SYMPTOMS

When you use an On Exit macro for a form field to go to a bookmark in an unprotected section of the document, the insertion point goes to the beginning of the section, not the bookmark location.

WORKAROUND

Add an additional text box after the form field that you want to cause the jump to your bookmark location. With that text box, assign either of the following Word Visual Basic for Applications procedures as an On Entry procedure:

   Sub WorkingGoto()
      ActiveDocument.Bookmarks("<your bookmark name>").Select
   End Sub

    -or-

   Sub WorkingGoto()
      Selection.Goto What:=wdGotoBookmark, Name:="<your bookmark name>"
   End Sub

To make the field less visible set the maximum length to 1, and remove the bookmark name in the Field Options dialog box.

NOTE: These code samples will not work in an On Exit macro when the bookmark is in the unprotected section of the document. If the bookmark is for another form field, then the code will work as an On Exit macro.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.

MORE INFORMATION

When you use the following code, you will not get the desired results, nor will you get an error message in Word.

   Sub GoToFails()
      ActiveDocument.Goto What:=wdGotoBookmark, Name:="test"
   End Sub

The wdGotoBookmark constant is not supported by the ActiveDocument property and the GoTo method of Word. This code will not move the insertion point or select the range the bookmark defines.

REFERENCES

For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q163435
   TITLE     : VBA: Programming Resources for Visual Basic for
               Applications

Additional query words: wordcon vb vba vbe
Keywords          : kbdta kbdtacode OffVBA kbmacroexample macword98 
Version           : MACINTOSH:98
Platform          : MACINTOSH
Issue type        : kbbug
Solution Type     : kbpending

Last Reviewed: February 15, 1999