Search code examples
excelvbalistboxselected

Listbox.Selected shows run time error '-2147024809(80070057)'


I have a listbox which is set to multi select. When I use listbox.selected to check the item selection status、I get the run time error. Run-time error '-2147024809(80070057)':Could not get selected property. Invalid argument.

There are 55 items set in the listbox. And when i=25, the error happens. What is the cause of this error?

' Add item to listbox
with me
    For i = LBound(arr) To UBound(arr)
      .ListBox1.AddItem arr(i)
    Next
End With

' Check listbox
with me
    arr = Array()
    For i = 0 To .ListBox1.ListCount - 1
      If .ListBox1.Selected(i) = False Then    <-Error happen here
        ReDim Preserve arr(UBound(arr) + 1)
        arr(UBound(arr)) = .ListBox1.List(i)
      End If
    Next
End With

Solution

  • The error disappeared after recreating the form and all related processing,