WD: WordBasic Examples: GotoNext/GotoPrevious

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
  • Microsoft 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 : kbprg kbdtacode wordnt kbmacroexample winword ntword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1; WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbhowto


Last Reviewed: December 23, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.