Oropi
02-13-2005, 08:54 PM
This code would work in Excel 97 (from the help file):
Dim EntryCount As Single
Private Sub CommandButton1_Click()
EntryCount = EntryCount + 1
ListBox1.AddItem (EntryCount & " - Selection")
End Sub
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount >= 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub
but, now that I have upgraded to Execl 2000 I get this error at "ListBox1.AddItem":
Error 80010108 Automation error. The object invoked has disconnected from its clients
Now I cannot use listboxes. Is there a workaround for this?
Dim EntryCount As Single
Private Sub CommandButton1_Click()
EntryCount = EntryCount + 1
ListBox1.AddItem (EntryCount & " - Selection")
End Sub
Private Sub CommandButton2_Click()
'Ensure ListBox contains list items
If ListBox1.ListCount >= 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = _
ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub
but, now that I have upgraded to Execl 2000 I get this error at "ListBox1.AddItem":
Error 80010108 Automation error. The object invoked has disconnected from its clients
Now I cannot use listboxes. Is there a workaround for this?