回 帖 发 新 帖 刷新版面

主题:导出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

End Sub


执行时报错定义的应用程序或对象错误,请哪位高手帮忙看看

回复列表 (共1个回复)

沙发

什么错。怎么错。截图

我来回复

您尚未登录,请登录后再回复。点此登录或注册