主题:导出excel报错
Private Sub Command3_Click()
On Error Resume Next
Dim i As Integer
Dim j As Integer
Dim XlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set XlApp = CreateObject("Excel.Application")
XlApp.Visible = True
Set xlBook = XlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlBook.Worksheets(1).Name = "aa"
xlSheet.Cells(1, 1) = "a"
xlSheet.Cells(1, 2) = "b"
xlSheet.Cells(1, 3) = "c"
xlSheet.Cells(1, 4) = "d"
xlSheet.Cells(1, 5) = "e"
xlSheet.Cells(1, 6) = "f"
xlSheet.Cells(1, 7) = "g"
xlSheet.Cells(1, 8) = "h"
xlSheet.Cells(1, 9) = "i"
xlSheet.Cells(2, 1).CopyFromRecordset DataGrid1.DataSource
On Error Resume Next
Dim i As Integer
Dim j As Integer
Dim XlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set XlApp = CreateObject("Excel.Application")
XlApp.Visible = True
Set xlBook = XlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
xlBook.Worksheets(1).Name = "aa"
xlSheet.Cells(1, 1) = "a"
xlSheet.Cells(1, 2) = "b"
xlSheet.Cells(1, 3) = "c"
xlSheet.Cells(1, 4) = "d"
xlSheet.Cells(1, 5) = "e"
xlSheet.Cells(1, 6) = "f"
xlSheet.Cells(1, 7) = "g"
xlSheet.Cells(1, 8) = "h"
xlSheet.Cells(1, 9) = "i"
xlSheet.Cells(2, 1).CopyFromRecordset DataGrid1.DataSource
End Sub
执行时报错定义的应用程序或对象错误,请哪位高手帮忙看看