I have a worksheet listbox that gets populated from a separate
module, with a list of files in a folder. With the list populated,
when I change the contents of the folder (delete or add files),
then repopulate the listbox, I see no change.
For example if I delete a file, it still appears after I repopulate the
llistbox, and it is the only one that can not be selected.
In the program, a Sheet1 media player control has been created
to play from the list, one at a time; the status of the WMP control is
checked from Sheet1 module to determine if the player is stopped,
and when it is, that control is deleted and a new control is created to
play the next in the list.
Is there a method to refresh or repaint the listbox from code in a module?
I'm using Excel 2003. Module1 code:
module, with a list of files in a folder. With the list populated,
when I change the contents of the folder (delete or add files),
then repopulate the listbox, I see no change.
For example if I delete a file, it still appears after I repopulate the
llistbox, and it is the only one that can not be selected.
In the program, a Sheet1 media player control has been created
to play from the list, one at a time; the status of the WMP control is
checked from Sheet1 module to determine if the player is stopped,
and when it is, that control is deleted and a new control is created to
play the next in the list.
Is there a method to refresh or repaint the listbox from code in a module?
I'm using Excel 2003. Module1 code:
Code:
Sub Populate_Listbox()
Dim FileList
Dim cMyListBox As MSForms.ListBox
Set cMyListBox = Sheet1.ListBox1
FileList = Dir(Get_Path & "*.mp3")
With cMyListBox
.Clear
While FileList <> ""
.AddItem FileList
FileList = Dir()
Wend
.Selected(0) = True
End With
Set cMyListBox = Nothing
End Sub