Excel VBA - UserForm ListBox未填充

时间:2012-12-13 06:48:11

标签: excel-vba vba excel

我在userform中添加了一个列表框。当我通过代码设置属性,添加项目等时,列表框中没有任何内容。我没有收到错误,列表框只是空白。 这是一个片段。我查看了列表框属性,Enabled和Visible为true,Locked为false。

Private Sub Refresh_Click()
ListBox1.Clear
Dim wb As Workbook
UserForm1.ListBox1.BackColor = RGB(5, 5, 5) 'threw this in for testing; box not changed
For Each wb In Workbooks
   MsgBox wb.Name
   ListBox1.AddItem wb.Name 
   'this is what I'm trying to accomplish; 
   'wb.Name shows in the MsgBox but not in the listbox
Next wb
End Sub

1 个答案:

答案 0 :(得分:2)

代码没有错误并且有效,但我必须更改列表框的前景才能看到项目

相关问题