Microsoft KB Archive/114345

= BUG: Is Operator in VBApp Incorrectly Evaluates Excel Objects =

Article ID: 114345

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 5.0 Standard Edition

-



This article was previously published under Q114345



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.



Steps to Reproduce Problem
 Start Microsoft Excel, or from the File menu, choose New (ALT, F, N) if it is already running. Insert a New module. From the Insert Menu, choose Macro Module (ALT, I, M, M). Module1 is created by default.  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  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: kbbug KB114345

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.