WD: Select Without End Select Error with Goto Statement

ID: Q95421


The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 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, 6.0.1a


SYMPTOMS

When you use a Microsoft WordBasic Goto statement within a Case instruction, the following WordBasic error may result:

"SELECT without END SELECT"
This error occurs if the Goto statement jumps out of the Case instruction before running an End Select statement.


WORKAROUND

To work around this error, add an additional End Select statement below the Goto label or place the Goto statement outside of the Case instruction.

NOTE: Jumping outside of a Select Case control structure with a Goto statement is not recommended. Each control structure should be self-contained.


STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Word listed at the beginning of this article. This problem was corrected in Word 97 for Windows and Word 98 Macintosh Edition.


MORE INFORMATION

Microsoft 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 the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/supportnet/refguide/

Example

The following sample macro includes a Goto statement within the Case instructions and thus results in a "SELECT without END SELECT" error.

   Sub MAIN
      n = 1
      Select Case n
         Case 1
            Goto Bye
         Case Else
      End Select
   Bye:
   End Sub 

Example Workarounds

Move the Goto statement outside of the Case instructions, as in the following sample macros:

   Sub MAIN
      n = 1
      If n = 1 then Goto Bye
      Select Case n
         Case 2
            Print "Case 2"
         Case Else
      End Select
   Bye:
   End Sub 

   Sub MAIN
      n = 1
      Select Case n
         Case 1
            GotoLoc = 1
         Case Else
      End Select
      If GotoLoc = 1 Then Goto Bye
   Bye:
   End Sub 
Add an additional End Select statement after the Goto label, as in the following macro sample:

   Sub MAIN
      n = 1
      Select Case n
         Case 1
            Goto Bye
         Case Else
      End Select
   Bye:
      End Select
   End Sub 


REFERENCES

"Using WordBasic" by WexTech Systems, Inc. and Microsoft Corporation, Microsoft Press, 1992, page 275.

Additional query words: error 130 winword2 8.0 8.00

Keywords : kbmacro wordnt word8 winword ntword macword word6 word7 word95
Version : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a; winnt:6.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbbug


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