运行时,ListItems显示蓝色,提示找不到方法或数据成员。请高手帮我。谢谢!
Private Sub Command1_Click()Dim i As Integer, j As Integer
Set xlApp = CreateObject("Excel.Application") '创建EXCEL应用类
xlApp.Visible = False '设置EXCEL不可见
Set xlBook = xlApp.Workbooks.Open(App.Path & "\data.xls") '打开EXCEL工作簿
Set xlsheet = xlBook.Worksheets(1) '打开EXCEL工作表
'xlsheet.Activate '激活工作表
Dim litem
For i = 2 To 7 '行/记录条数
Set litem = ListView1.ListItems.Add()
litem.Text = xlsheet.Cells(i, 1)
litem.SubItems(1) = xlsheet.Cells(i, 2)
litem.SubItems(2) = xlsheet.Cells(i, 3)
litem.SubItems(3) = xlsheet.Cells(i, 4)
'MsgBox xlsheet.Cells(i, j)
Next
xlBook.Close (True) '关闭EXCEL工作簿
xlApp.Quit '关闭EXCEL
Set xlApp = Nothing '释放EXCEL对象
End Sub