Code generated ComboBox (ActiveX)

Vishesh's picture
Manually add a combobox to Activesheet and right click to see its properties.

Next, run the following code to add a combobox through code and right click - you won't be able to see the properties now.

Right click on the code-generated control and choose Group->Ungroup as many times to ungroup the control and it is ungrouped into multiple shapes.

Conclusion: The controls added through code are different from the ones manually added.

Sub TestCode()
    Dim abc As OLEObject
 
    Set abc = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, _
        DisplayAsIcon:=False, Left:=312.75, Top:=99.75, Width:=188.25, Height _
        :=24.75)
    'If you right click on the combobox thus created you won't be able to view its properties
    'as against the one manually added.
    
    abc.Object.AddItem "A"
    'abc.Object.ListFillRange = "A1:A2" 'This doesn't work
    
    Set abc = Nothing
End Sub