我创建了一个应用程序,它接受一个Excel文件并将其插入到我的访问数据库表中。 我在计算机中使用了Microsoft Access 15.0对象库。 但当我在另一台使用Access 2007的计算机上执行应用程序时,它会立即停止。 这是代码:
Private Sub xlsTomdb() On Error GoTo err_handler Dim oAccess As Access.Application Set oAccess = CreateObject("Access.Application") oAccess.Visible = False oAccess.OpenCurrentDatabase App.Path + "\archivi.mdb", True oAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "EXCEL", App.Path + "\Export\Final.xls", True oAccess.Quit err_handler: MsgBox "The code failed at line " & Erl, vbCritical End SubmsgBox显示“代码作为第0行失败”。 当我删除错误处理程序时,程序继续正常执行。 在使用Office 2007的另一台PC上运行该程序时,它终止于此功能,运行时出现错误[-2147467259(80004005)microsoft odbc microsoft access driver type mismatch in expression]
此功能在按钮单击事件上执行。 有没有理由不开放访问2007,因为我在构建它时使用了Access 2013?
有人可以帮忙吗?
I have created a application that takes an Excel file and inserts it into my access database table. I used Microsoft Access 15.0 Object Library in my computer . But when I executed the application it in an another computer with Access 2007 it stops immediately. This is the code:
Private Sub xlsTomdb() On Error GoTo err_handler Dim oAccess As Access.Application Set oAccess = CreateObject("Access.Application") oAccess.Visible = False oAccess.OpenCurrentDatabase App.Path + "\archivi.mdb", True oAccess.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "EXCEL", App.Path + "\Export\Final.xls", True oAccess.Quit err_handler: MsgBox "The code failed at line " & Erl, vbCritical End SubThe msgBox shows "The code failed as line 0". When I removed the Error Handler the program continues the execution normally. While running the program on another PC with Office 2007 it terminates at this function with runtime error [-2147467259 (80004005) microsoft odbc microsoft access driver type mismatch in expression]
This function is executed on button click event. Is there any reason not to open access 2007, because I used Access 2013 while building it?
Can anyone help?
最满意答案
EBalla:
“Microsoft Access 15.0对象”或DAO 15库属于Office 2013.早期版本不会了解此库。 如果您的目标计算机使用的是Office 2007,则需要在项目中添加引用“Microsoft Access 12.0对象库”。 您遇到兼容性问题而不是代码问题。
另请查看: http : //allenbrowne.com/ser-38.html
EBalla:
"Microsoft Access 15.0 Object" or DAO 15 library belongs to office 2013. Earlier versions will not know about this library. if your target machines are using office 2007 you need to add the reference "Microsoft Access 12.0 Object library" into your project. You are experiencing compatibility issue rather than code issue.
also check this out: http://allenbrowne.com/ser-38.html
更多推荐
发布评论