如何使用Excel VBA在运行时打开MS Access?

时间:2022-12-20 15:25:51

I'm struggling on how to open MS Access Runtime using VBA, from an Excel file.

我正在努力研究如何使用VBA从Excel文件打开MS Access Runtime。

You can open the full version of Access using CreateObject("Access.Application"), but that doesn't open Access in Runtime.

您可以使用CreateObject(“Access.Application”)打开完整版Access,但这不会在运行时打开Access。

We only have Microsoft Access Runtime installed in some computers, because that's all we need to use the front-ends we've developed. So we need to open the accdb files using MS Access Runtime, but from Excel.

我们只在某些计算机上安装了Microsoft Access Runtime,因为我们需要使用我们开发的前端。所以我们需要使用MS Access Runtime打开accdb文件,但是需要从Excel打开。

Any help is appreciated, thank you

感谢任何帮助,谢谢

1 个解决方案

#1


2  

You can use the Shell to open a file, as if you typed that command into window's command prompt.

您可以使用命令行管理程序打开文件,就像在窗口的命令提示符下键入该命令一样。

d = Shell("pathToFile\Database1.accdb /runtime", vbNormalFocus)

Another option you could use to open in the file in runtime (if someone opens it from the folder or through some other method without the /runtime switch) would be to change the file extension to .accdr. This will always force runtime.

您可以用来在运行时在文件中打开的另一个选项(如果有人从文件夹或通过其他方法打开它而没有/ runtime开关)将文件扩展名更改为.accdr。这将始终强制运行时。

#1


2  

You can use the Shell to open a file, as if you typed that command into window's command prompt.

您可以使用命令行管理程序打开文件,就像在窗口的命令提示符下键入该命令一样。

d = Shell("pathToFile\Database1.accdb /runtime", vbNormalFocus)

Another option you could use to open in the file in runtime (if someone opens it from the folder or through some other method without the /runtime switch) would be to change the file extension to .accdr. This will always force runtime.

您可以用来在运行时在文件中打开的另一个选项(如果有人从文件夹或通过其他方法打开它而没有/ runtime开关)将文件扩展名更改为.accdr。这将始终强制运行时。