BUG: Is Operator in VBApp Incorrectly Evaluates Excel Objects (114345)



The information in this article applies to:

  • Microsoft Excel for Windows 5.0

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.

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.

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbbug KB114345