回复 4楼 Artless
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Private Sub Command1_Click()
Dim I As Integer, j As Integer
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False
FileName = Dir(App.Path & "\*.xls")
Do While FileName <> ""
If InStr(1, CStr(FileName), "Data", vbTextCompare) > 0 Then
Set xlBook = xlApp.Workbooks.Open(App.Path & "\" & FileName)
Set xlsheet = xlBook.Worksheets(1)
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)
Next
xlBook.Close (True)
xlApp.Quit
Kill App.Path & "\" & FileName
End If
FileName = Dir
Loop
Set xlApp = Nothing
MsgBox "Done"
End Sub
问题解决了!!谢谢大家!!
[
本帖最后由 yuk_yu 于 2012-12-19 16:22 编辑 ]