看到网上的一些导出例子是用 复制拷贝 的方法 把子窗体内容导出,在记录多的时候就很慢
下面是我结合从网上找到的一些资料和查自带帮助 写下的,希望给大家带来方便
Private Sub ImportToExcel()
Dim oExcel As Object
Dim oBook As Object
Dim i As Integer
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add()
Me.子窗体.Form.Recordset.MoveFirst
For i = 0 To Me.子窗体.Form.Recordset.Fields.Count - 1
oBook.Worksheets(1).Cells(1, i + 1).Value = Me.子窗体.Form.Recordset.Fields(i).Name
Next
oBook.Worksheets(1).Range("A2").CopyFromRecordset Me.子窗体.Form.Recordset
oBook.SaveAs ("d:\Test.xls")
oBook.Close False
oExcel.Quit
Set oBook = Nothing
Set oExcel = Nothing
End Sub
[此贴子已经被作者于2005-8-15 19:23:51编辑过]
|