通过Excel VBA打开Access 2003 .mde文件
我正在尝试使用Excel VBA打开Access 2003 .mde文件。
到目前为止我已经尝试过:
Shell ("cscript "C:\User\Folder\Access Database.mde""), vbHide
现在,这完美地打开.vbs文件,代码运行打开.mde文件,但实际上并没有打开数据库。
我也尝试了以下内容:
strdb = "C:\User\Folder\Access Database.mde" Set AccessApp = CreateObject("Access.Application") AccessApp.Visible = True AccessApp.OpenCurrentDatabase.strdb AccessApp.DoCmd.OpenForm "frmsysteminformation" Set AccessApp= Nothing
我发现这个在线,但它给我一个debugging错误突出显示的行:
Set AccessApp = CreateObject("Access.Application")
谢谢
编辑我的公司似乎已经禁用了一些function
CreateObject("Outlook.Application")
也不起作用。 有没有办法通过cscript运行这个?
为了防止任何人在同一个问题上绊倒,我设法解决了这个问题:
Dim sAcc Dim sFrontEnd Dim sSec Dim sUser Dim objShellDb Dim sComTxt 'Script Configuration Variable '******************************************************************************* 'Specify the Fullpath and filename of the msaccess executable sAcc = "C:\Program Files\Microsoft Office\Office11\MSACCESS.EXE" 'Specify the Fullpath and filename of the database to launch sFrontEnd = "C:\users\file location\Database to open.mde" Set objShellDb = CreateObject("WScript.Shell") 'Build the command to launch the database sComTxt = Chr(34) & sAcc & Chr(34) & " " & Chr(34) & sFrontEnd & Chr(34) objShellDb.Run sComTxt 'Launch the database End Sub