How to cast a shape object?
I want to assign a ComboBox
control to a class member of ComboBox
type. This control is in a group on 开发者_如何学Goa worksheet.
The problem is through GroupItems
property, I can only get a Shape
object, not a ComboBox
. So when assigning, it alerts "type mismatch".
If the control was not in a group, I could get an OLEObject
object through OLEObjects
property, and then use Object
property to bypass the type mismatch. But what about now?
Once you have your Shape object, whether it is in a Group or not, you can access the ComboBox through the DrawingObject.Object property. So it would look something like
Set cboVariable = ActiveSheet.Shapes(1).GroupItems(2).DrawingObject.Object
精彩评论