报错  Run-time error '3170'
      Couldn't find installable ISAM.
我的函数简化如下:
'***************************************************************************************
'MSHFlexGrid控件的导出
Public Function FlexExportE(ByVal Flex1 As MSHFlexGrid, ByVal CommonDialog1 As CommonDialog)
    mvarVersion = vbLBV5
    Dim SaveFilePath As String
    Dim EXEString As String
    Dim i As Integer, j As Integer
    Dim InsertAmount As Integer
    Dim WS As DAO.Workspace
    Dim DB As DAO.Database
    Dim TABL As DAO.TableDef
    Dim RS As DAO.Recordset
    'On Error GoTo err_handle
   ' On Error Resume Next
    With CommonDialog1
        .CancelError = False
        .Filter = "Excel文件(*.xls)|*.xls"
        .DialogTitle = "将数据导出到Excel表(5.0)"
        .ShowOpen
        If Trim(.FileName) = "" Then
         Exit Function
        End If
        
        SaveFilePath = .FileName
    End With
    'If flex1.ColumnHeaders.Count <= 0 Then
    ' Exit Sub
    'End If
    
    Dim MyFile
    MyFile = Dir(SaveFilePath)
    Dim Msg As Integer
    If MyFile <> "" Then
        Msg = MsgBox("是否要覆盖原文件!", vbInformation + vbYesNo, "提示")
        If Msg = 7 Then
            Exit Function
        Else
        Kill (MyFile)
        End If
    End If
        
        
    
    Set WS = DBEngine.CreateWorkspace("WS", "Admin", "", dbUseJet)
    
    Dim mdbFile
    mdbFile = Dir(App.Path & "\report\FlexToExcel.mdb")
    If mdbFile <> "" Then
        Kill App.Path & "\report\FlexToExcel.mdb"
    End If
'    Set DB = WS.CreateDatabase(App.Path & "\report\FlexToExcel.mdb",  dbLangGeneral, dbEncrypt)
    Set DB = WS.CreateDatabase(App.Path & "\report\FlexToExcel.mdb", dbLangGeneral, dbEncrypt)
    Set TABL = DB.CreateTableDef("Excel")
'    For i = 1 To Flex1.Cols - 1
'        TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, i), dbText, 250)
'        'TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, i), dbSingle, 250)
'    Next i
    
        TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 0), dbText, 250)   '流水号
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 1), dbText, 250)    'emp_id1
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 2), dbText, 250)    '部门
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 3), dbText, 250)    '工号
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 4), dbText, 250)    '姓名
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 5), dbText, 250)    '月份
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 6), dbDouble, 250)    'base
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 7), dbDouble, 250)    '岗位
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 8), dbDouble, 250)    '津贴
    TABL.Fields.Append TABL.CreateField(Flex1.TextMatrix(0, 9), dbDouble, 250)    '技能
    
    DB.TableDefs.Append TABL
    Set RS = DB.OpenRecordset("Excel")
    If Flex1.Rows > 1 Then
            InsertAmount = Flex1.Cols - 1
        For i = 1 To Flex1.Rows - 1
            RS.AddNew
            'RS.Fields(0) = Flex1.ListItems.Item(i).Text
            'RS.Fields(0) = Flex1.TextMatrix(i, 1)
            For j = 0 To InsertAmount
                If Flex1.TextMatrix(i, j) <> "" Then
                    RS.Fields(j) = Flex1.TextMatrix(i, j)
                ElseIf Flex1.TextMatrix(i, j) = "" Then
                    RS.Fields(j) = "//"
                End If
            Next j
            RS.Update
        Next i
    End If
    EXEString = "select * into [Excel " & Format(CStr(mvarVersion), "0.0") & ";database=" & SaveFilePath & "].LBExcel from Excel"
    DB.Execute EXEString
    RS.Close
    DB.Close
    WS.Close
    Kill App.Path & "\report\FlexToExcel.mdb"
    MsgBox "导出数据到Excel表成功!", vbInformation, "提示"
    Exit Function
err_handle:
    Select Case Err
        Case 53:
            Resume Next
    End Select
End Function

解决方案 »

  1.   

    也不是每台机器都报错。这跟EXCEL ACCESS的环境是不是相关的。
    我本来不报错的,新装的系统就报错。哎,调不过去了。高手帮忙。
      

  2.   

    和开发环境使用的office的版本有关系,2003下开发的不能在2000下完全正常的使用。确认一下出错的电脑的office版本
      

  3.   

    1,建议你看看这个帖。
    2、连接字符写错,但是如有机器能运行你的代码,则不属于连接字符问题。
    3、不属于上面问题,检查office版本,如office2K环境下开发的程序在office97下的驱动就是不同的。