I am having a problem trying to select items from a listbox that is drawn on my worksheet. I have no problem adding items, or removing items.... only when I try to identify the items that are selected.
There is no ".Selected" in the intellisense for either the object directly, or the object.ControlF ormat. When I execute this code, Excel fails with the error message: "Runtime Error 438. Object doesn't support this property or method."
I've scoured the net looking for help, but couldn't find any that addressed this issue.
Anybody have insight on how to either fix the problem or a workaround where I can see what items are selected and dump them into a collection?
' I tried all three modes of the listbox (single, multi, extended - select), which is available when right-clicking the control.
There is no ".Selected" in the intellisense for either the object directly, or the object.ControlF ormat. When I execute this code, Excel fails with the error message: "Runtime Error 438. Object doesn't support this property or method."
I've scoured the net looking for help, but couldn't find any that addressed this issue.
Anybody have insight on how to either fix the problem or a workaround where I can see what items are selected and dump them into a collection?
' I tried all three modes of the listbox (single, multi, extended - select), which is available when right-clicking the control.
Code:
' Dimension variables and objects
Dim ws As Excel.Worksheet
Dim lst As Shape
Dim cList As Collection ' The index of the "Selected" currencies
Dim i As Integer ' Loop variable
' Set objects
Set ws = Application.Sheets(MAIN_SHEET)
Set lst = ws.Shapes("lstCurrencies")
Set cList = New Collection
' Set the Selected Items
With lst.ControlFormat
For i = 1 To .ListCount
If .Selected(i) Then ' [B]<---- FAILS HERE[/B]
cList.Add lst.ControlFormat.List(i)
.Selected(i) = False
End If
Next i
End With
Comment