The information in this article applies to:
SYMPTOMSWhen you run a Visual Basic for Applications macro in Microsoft Excel 97, you may receive one of the following error messages:
-or-
-or- If you click Debug to check the value of a variable in the Immediate window, you may receive the following error message: If you click Details, you receive an error message similar to the following: and Microsoft Excel 97 stops responding. CAUSE
This problem occurs when all of the following conditions are true:
WORKAROUNDMicrosoft 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/support/supportnet/overview/overview.aspThe following macro moves Sheet1 from the active workbook into a new workbook:
If you attempt to check the value of xSheet after moving the sheet to the
new workbook, the error appears. For example, the following line of code
fails because xSheet refers to a worksheet that no longer exists in the
same workbook:
To work around this problem, redefine the variable to point to the new
location of the sheet. Or, set the value of the variable equal to Nothing.
To do this, use either of the following methods:
Method 1: Set the Variable to Point to the New Location of the Worksheet
Method 2: Set XSheet Equal to Nothing
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem no longer occurs in Microsoft Excel 2000. MORE INFORMATIONIn earlier versions of Microsoft Excel, if you create a variable that refers to a sheet, and then move that sheet to another workbook, the variable continues to find to the sheet in its new location. For example if you run the following subroutine in Microsoft Excel 5.0 or 7.0, the MsgBox displays the name of the moved sheet ("Sheet1 (2)") even when you move the worksheet to a different workbook:
In Microsoft Excel 97, this macro does not work correctly, because the
variable xSheet cannot find the moved sheet in its new location. This
change in behavior may cause problems if your code assumes that the
variable continues to refer to the sheet even if it is moved. In this case,
use the first method to redefine the variable to refer to the sheet in the
new location.
Additional query words: XL97 crash hang
Keywords : kberrmsg kbdta KbVBA xlvbmigrate |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |