首先要创建execl就用对象以后才可以创建工作薄
dim xls as object
dim sheet as object
set xls=createobject("Excel.Application")
set sheet=createobject("xls.sheet")

解决方案 »

  1.   

    up
    give you advice later!
      

  2.   

    kingbear2000(相信自己)  is right
      

  3.   

    我用了kingbear2000(相信自己)的方法,结果连原来可以正常导出的机器上,现在也统统不行了。还有没有别的方法?
      

  4.   

    我又另外一个方法,将结果集写入到EXCEL中:
    Public Sub SaveTestData()
    Dim nLoopRow As Integer
    Dim nLoopCol As Integer
    Dim nChannel As Integer
    Dim TempDate
    Dim sOutPut(7) As String
    Dim strlog As String
    nChannel = FreeFile
    If fMainForm.grdResults.Cols > 0 ThenOpen App.Path & "\" & App.EXEName & ".csv" For Append As #nChannel
    For nLoopRow = 0 To fMainForm.grdResults.Rows - 1
        fMainForm.grdResults.Row = nLoopRow 'Ö¸Ïòµ±Ç°ÐÐ
        For nLoopCol = 0 To fMainForm.grdResults.Cols - 1
           fMainForm.grdResults.Col = nLoopCol
           sOutPut(nLoopCol) = fMainForm.grdResults.Text
            'Write #nChannel, sOutPut(0),
        Next nLoopCol
       Write #nChannel, sOutPut(0), sOutPut(1), sOutPut(2), sOutPut(3), sOutPut(4), sOutPut(5), sOutPut(6)
    Next nLoopRow
    Close #nChannel
    End If
    End Sub注意:
    我是将fMainForm.grdResults (MSFLEXGRID)控件中的内容输出,
      

  5.   

    Set ExcelApp = CreateObject("Excel.Application")
        ExcelApp.Workbooks.Open FileName:=XlsName
        If Val(ExcelApp.Application.Version) >= 8 Then
            Set ExcelSheet = ExcelApp.ActiveSheet
        Else:
            Set ExcelSheet = ExcelApp
        End If
      

  6.   

    你自己的是對的
    你怕不對
    用這個方法去檢驗一下﹐看看到底有沒有生成xl對象﹕    Dim xl As Object
        Set xl = CreateObject("excel.sheet")
        xl.Parent.Visible = True
        Set xl = Nothing是OK的
      

  7.   

    怎么都是这种中方法啊,使用DAO 或ADO 接口,直接应用SQL语句就可以把MDB文件中的所有内容导入到xls, mdb, txt, dbf, db 等格式。 我有源代码,但是写的不太好,谁要给我发邮件。 [email protected] 我可以发给大家。