报错 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
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
解决方案 »
- 如何判断一字符串在一个数组中
- width相同的控件显示却不一样大,是何故?
- 请教个vb的form上去掉关闭按钮的问题
- vb图像压缩处理
- 动态生成TextBox和RichTextbox控件的问题
- DataReport报表的筛选打印问题
- 如何改变鼠标的指针!!!!!!!?????
- 请给出Polygon,Polyline,POINTAPI的详细用法!!!
- 不安!散分
- 谁有支持SMTP验证的,可以发送附件的,WINSOCK源码?多谢了。
- 拥护定义类型未定义 的小错误 怎么改??帮忙看看
- 我想把一个数据库中表的值赋给另一个数据库的表。两个表的字段名不一样!例如:原字段为:bj_gcmc,而现在的为gcmc。而且两个表的字段数不
我本来不报错的,新装的系统就报错。哎,调不过去了。高手帮忙。
2、连接字符写错,但是如有机器能运行你的代码,则不属于连接字符问题。
3、不属于上面问题,检查office版本,如office2K环境下开发的程序在office97下的驱动就是不同的。