请教有用excel做过报表的gg
Private Sub Command1_Click()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.ConnectionString = "dsn=kkk;uid=sa;pwd=123"
cn.Open
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "table6", cn, adOpenDynamic, adLockOptimistic, adCmdTable
rst.MoveFirst
Dim a As Integer
Dim m As Integer
Dim n As Integer
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Set xlApp = CreateObject("Excel.Application") Dim xlbook As Excel.Workbook
Set xlbook = xlApp.Workbooks.Open("d:\h.xls")
Dim xlsheet As Excel.Worksheet
Set xlsheet = xlbook.Worksheets("sheet1")
xlsheet.Select
For m = 1 To a
For n = 1 To 2
xlsheet.Cells(m, n) = rst.Fields(n - 1)
Next n
rst.MoveNext
Next m
xlApp.Visible = True
End Sub
为什么不能导出?