You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible to add an ActiveX control to a sheet, and name the hosting Shape as Name which shadows/conflicts with the Name property of a Worksheet class. That makes for a disconnect between the shape name and the name of the WithEvents object that sources events in the sheet's code-behind.
RD should have an inspection that looks for such naming conflicts.
The VBA to get the real control name requires explicitly casting the OLEObject.Object to the underlying type:
DimoleobjAsOLEObjectSetoleobj=Sheet1.OLEObjects("Name")Debug.PrintTypeName(oleobj.Object)'Prints "CommandButton"Debug.Printoleobj.Object.Name'Runtime error 438 - Object doesn't support this property or methodDimcbAsCommandButtonSetcb=oleobj.ObjectDebug.Printcb.Name'Prints "NameFoo"
Note that the similar problem exist in Access, where by default adding a control to form is given the same name as the backing field. This has the effect of shadowing the Access.AccessField with the Access.Control; an inspection should recommend renaming control so they are distinct. If there are other cases like that, it might be more desirable to make this inspection more generic and extensible so that it can be easily set up to check for different collections that may contain the conflicting names.
Wouldn't the upcoming ShadowedDeclarationInspection would/should take care of this... if we picked up document-embedded OLEObject controls? If every Worksheet module had a "hidden" Control declaration for every embedded OLEObject control on the sheet, then a name clash would be picked up automagically already, wouldn't it?
It's possible to add an ActiveX control to a sheet, and name the hosting
Shape
asName
which shadows/conflicts with theName
property of a Worksheet class. That makes for a disconnect between the shape name and the name of theWithEvents
object that sources events in the sheet's code-behind.RD should have an inspection that looks for such naming conflicts.
The VBA to get the real control name requires explicitly casting the
OLEObject.Object
to the underlying type:ref: #389
The text was updated successfully, but these errors were encountered: