Set objAccess = CreateObject("Access.Application")
那个时候我到了
错误429“ActiveX组件无法创建对象 . ”
建议如何创建对象?
1 回答
0
我不确定这些信息是否仍与OP相关,但它可能有助于其他人(比如我)寻找解决方案的人:
在简单路线的情况下
Dim AccApp as Object
Set AccApp = CreateObject("Access.Application")
不起作用(例如,因为只有Access的Runtime版本可用),以下路由似乎有效:
Const PathToDBFile as String = "W:\here\Your\DB\lies.accdb"
Const PathToAccess as String = "C:\Program files\YourOfficeVersion\MSACCESS.EXE"
Dim ShellCmd as String
' Piece together the parts (yes, the quotes are necessary in case there are spaces in the paths)
ShellCmd = """" & PathToAccess & """ """ & PathToDBFile & """"
' Execute the command in the shell
VBA.Shell ShellCmd
' Now GetObject can return the newly created instance of Access
Dim AccApp as Object
Set objAcc = GetObject(PathToDBFile)
1 回答
我不确定这些信息是否仍与OP相关,但它可能有助于其他人(比如我)寻找解决方案的人:
在简单路线的情况下
不起作用(例如,因为只有Access的Runtime版本可用),以下路由似乎有效:
(Source)
这段代码只是显示基本步骤的简单方法 . 有人可能想确保我还没有弄清楚如何在不同系统上可靠地获取MSAccess.exe的路径 . 但是当我尝试安装只运行Runtime Version的系统时,上面的工作对我有用 . (我能够从
AccApp.Run "MyFunction"
获得正确的回报 . )