WD: WordBasic Examples: GotoNext/GotoPrevious

Last reviewed: February 2, 1998
Article ID: Q105862
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Word for the Macintosh, versions 6.0, 6.0.1

SUMMARY

This article contains a sample macro that demonstrates the use of the following WordBasic statements or functions:

   GoToNextAnnotation         GoToPreviousAnnotation
   GoToNextEndnote            GoToPreviousEndnote
   GoToNextFootnote           GoToPreviousFootnote
   GoToNextPage               GoToPreviousPage
   GoToNextSection            GoToPreviousSection
   GoToNextSubdocument        GoToPreviousSubdocument

This article supplements the information in online Help. To open this Help topic in Word for Windows, click Contents on the Help menu and then choose the "Programming with Microsoft Word" topic. In Word for the Macintosh, click the Help icon and select Microsoft Word Help. Choose the "Programming with Microsoft Word" topic.

MORE INFORMATION

The commands listed in the "Summary" section of this article are single line commands. They have no arguments and are used to move to specified parts of the document.

Example

The macro below could be used to go to different parts of the active document. In all instances the GoToNextCommand could be replaced with GoToPreviousCommand. If the item selected to go to does not exist, the insertion point will not move.

   Sub MAIN
      Begin Dialog UserDialog 225, 146, "Goto"
      OKButton 36, 118, 88, 21
      CancelButton 129, 119, 88, 21
      OptionGroup  .HelpChoice
         OptionButton 12, 6, 180, 16, "Next Annotation", .OptionButton1
         OptionButton 12, 23, 180, 16, "Next Endnote", .OptionButton2
         OptionButton 12, 40, 180, 16, "Next Footnote", .OptionButton3
         OptionButton 12, 57, 180, 16, "Next Page", .OptionButton4
         OptionButton 12, 74, 127, 16, "Next Section", .OptionButton5
         OptionButton 12, 91, 172, 16, "Next Subdocument",
      .OptionButton6
      End Dialog
      Dim dlg As UserDialog
      GetCurValues dlg
      n = Dialog(dlg)
      If n = 0 Then Goto bye
      Select Case dlg.HelpChoice
         Case 0
            GoToNextAnnotation         ' Any of the above commands would
         Case 1                        ' work inserted here.
            GoToNextEndnote
         Case 2
            GoToNextFootnote
         Case 3
            GoToNextPage
         Case 4
            GoToNextSection
         Case 5
            GoToNextSubdocument
      End Select
   bye:
   End Sub


Additional query words:

Keywords : kbmacroexample macword ntword winword word6 word7 word95 wordnt kbcode kbprg
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.