如何以编程方式将ACCDB转换为MDB?

时间:2013-02-20 08:24:17

标签: ms-access ms-access-2010 ms-jet-ace ms-access-97

有没有办法以编程方式将Access 2010 ACCDB文件转换为Access 95/97 MDB文件?

1 个答案:

答案 0 :(得分:0)

以下是一些注意事项。我没有旧版本可以使用,所以我不知道你是否可以导入超出你可以导出的内容:

Dim ws As Workspace
Dim db As Object
Dim tdf As TableDef
Dim qdf As QueryDef
Dim dbExp As Database
Dim acApp As New Access.Application

acApp.OpenCurrentDatabase "z:\docs\demo.accdb"
Set dbExp = acApp.CurrentDb

Set ws = DBEngine.Workspaces(0)
FName = "z:\docs\oldver95.mdb"
''Access 95
Set db = ws.CreateDatabase(FName, dbLangGeneral, dbVersion30)
''You can only export tables and a limited range of datatypes
For Each tdf In dbExp.TableDefs
    If Left(tdf.Name, 4) <> "Msys" Then
        acApp.DoCmd.TransferDatabase acExport, "Microsoft Access", _
           FName, acTable, tdf.Name, tdf.Name
    End If
Next

请参阅http://msdn.microsoft.com/en-us/library/office/bb243161(v=office.12).aspx

使用VBScript演示使用引擎的一些注意事项:

Dim objEngine
Dim objWS
Dim objDB
Dim db: db = "z:\docs\oldver95.mdb"

Set objEngine = CreateObject("DAO.DBEngine.36")
Set objDB = objEngine.OpenDatabase(db)

strSQL="SELECT * FROM Table1"

objDB.CreateQueryDef "Query1", strSQL