你的是用recordset 的,
我的如下:
Dim objFileSystem As Object
Dim objExcelText As Object
Dim i, j As Integer
Dim num As Integer
Dim usrow As Integer
num = 1
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Open("D:\材料追踪.xls")
Set xlsheet = xlBook.Worksheets(1)
xlsheet.Activate
'清除Excel中原有的信息
usrow = xlsheet.UsedRange.Rows.count
For i = 5 To usrow
xlsheet.Cells(i, 1) = ""
xlsheet.Cells(i, 2) = ""
xlsheet.Cells(i, 3) = ""
xlsheet.Cells(i, 4) = ""
xlsheet.Cells(i, 5) = ""
Next
xlsheet.Cells(2, 5) = "" '清除时间
'将数组中的数据逐个复制到Ecxel报表的单元格中
For i = 1 To (aNum - 1) / 5 ' aNum-1是个全局变量,数值从 cmdOK_Click()事件中得到,表示数组的大小
For j = 1 To 5
xlsheet.Cells(4 + i, j) = a(num)
num = num + 1
Next
Next
xlsheet.Cells(2, 5) = Format(Now, "AMPM(YYYY-MM-DD hh:mm:ss)")
感谢帮助!