BUG: Is Operator in VBApp Incorrectly Evaluates Excel Objects

Last reviewed: July 29, 1997
Article ID: Q114345
The information in this article applies to:
  • Microsoft Visual Basic, Applications Edition, version 1.0
  • Microsoft Excel, version 5.0

SYMPTOMS

Using the Is operator to evaluate whether or not two object variables reference the same Microsoft Excel object, incorrectly evaluates to False.

WORKAROUND

Using a property of an object, such as Name, correctly evaluates whether or not the objects are the same. For example:

   If xlObject1.Name = xlObject2.Name then
      ' Code when the objects refer to our code
   End If

STATUS

Microsoft has confirmed this to be a bug in Microsoft Visual Basic, Applications Edition, version 1.0 that ships with Microsoft Excel version 5.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Microsoft Excel, or from the File menu, choose New (ALT, F, N) if it is already running.

  2. Insert a New module. From the Insert Menu, choose Macro Module (ALT, I, M, M). Module1 is created by default.

  3. Insert the following code into Module1:

       Sub TestXLObject()
          dim xlObject as Object
          Worksheets(1).Select
          set XlObject = Selection
          If xlObject Is xlObject then beep
       End sub
    
    

  4. Run the macro. From the Tools Menu, choose Macro (press ALT, T, M). From the Macro dialog, select the macro TestXLObject, and press the Run button.

You would expect to hear a beep to indicate expression 'xlObject Is xlObject' is true, but no beep sounds.
Keywords          : kbprg
Version           : 1.00 5.00
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbworkaround


================================================================================


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: July 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.