Error Message: WordBasic Err=39! Case Else ExpectedLast reviewed: July 30, 1997Article ID: Q97173 |
The information in this article applies to:
SYMPTOMSA Word for Windows macro stops and returns the following error message when you pass a value that is outside the range of defined cases in a Select Case statement:
WordBasic Err=39! Case Else ExpectedYou should add a Case Else statement to your macro that includes instructions for undefined Case values.
MORE INFORMATIONThe macro below gives an example of a valid Case Else statement. WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code 'as is' without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Sub MAINDim Musicians$(3) Musicians$(0) = "Please enter a number between 1 and 3" Musicians$(1) = "Jimi Hendrix" Musicians$(2) = "Buddy Holly" Musicians$(3) = "Elvis Presley" Input "Enter a number from 1 to 3", Musician Select Case Musician Case 0 To 3 Print Musicians$(Musician)Case Else Print "Enter a number between 1 and 3."End Select Done: End SubNote: Case statements look for numeric variables. Alphabetic characters are interpreted as 0 (zero). When you write a macro, be sure your Case statements account for the possibility of alphabetic instead of numeric input.
Sample Macro That Causes Error MessageIn the following sample macro, if you enter one of the four defined variables (namely, 0, 1, 2, or 3), the macro runs correctly. If you enter any other number (such as 5), the Select Case statement cannot interpret the input and returns the error message.
Sub MAINDim Musicians$(3) Musicians$(0) = "Please enter a number between 1 and 3" Musicians$(1) = "Jimi Hendrix" Musicians$(2) = "Buddy Holly" Musicians$(3) = "Elvis Presley" Input "Enter a number from 1 to 3", Musician Select Case Musician Case 0 To 3 Print Musicians$(Musician)End Select Done: End Sub |
KBCategory: kbmacro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |