I have a form with many multiselect listboxes on it. I want to loop through each list box and get the selected items to copy to excel. I am getting a casting error "must be less than infinity"
For Each box As Object In Me.Controls '****INFINITY ERROR*****
If TypeOf box Is ListBox AndAlso Name.Contains(head.Name) Then
'If box.Name.Contains(head.Name) Then
Dim itms As ListBox.SelectedObjectCollection
itms = box.SelectedItems
excel.ActiveCell.Value2 = itms
excel.ActiveCell.Offset(+1, 0).Select()
'End If
End If
Next
Jacque
For Each box As Object In Me.Controls '****INFINITY ERROR*****
If TypeOf box Is ListBox AndAlso Name.Contains(head.Name) Then
'If box.Name.Contains(head.Name) Then
Dim itms As ListBox.SelectedObjectCollection
itms = box.SelectedItems
excel.ActiveCell.Value2 = itms
excel.ActiveCell.Offset(+1, 0).Select()
'End If
End If
Next
Jacque