使用 VBA 打开时,如何允许数据库运行 activex 内容? [英] How do I allow databases to run activex content when opened with VBA?
问题描述
在 Access 2013(64 位)中,当用户单击 db1 中表单上的按钮时,我正在打开另一个数据库 (db2).这是有效的.但是,当它打开 db2 时,我收到警告栏安全警告:某些活动内容已被禁用.单击以获取更多详细信息",并带有一个按钮以启用该内容.这很烦人,当我从 db1 打开数据库并打开表单时,当我单击按钮启用内容时,所有当前打开的表单都已关闭.
In Access 2013 (64-bit) I'm opening another database (db2) when the user clicks a button on a form in db1. This is working. However, when it opens db2 I get the warning bar "Security warning: Some active content has been disabled. Click for more details" with a button to enable the content. This is annoying and when I open the database from db1 with forms also opened, when I click the button to enable the content all currently open forms are closed.
两个数据库都在同一个目录下,我已经把这个目录添加到了受信任的位置.我还需要做些什么来禁用此警告栏而不自动信任所有数据库(我不想做的事情)?
Both databases are in the same directory, and I have added this directory to the trusted locations. Is there something else I need to do to disable this warning bar without automatically trusting all databases (something I don't want to do)?
当我手动打开每个数据库时,我没有看到警告栏出现,所以我认为这与我使用的 VBA 代码有关:
When I manually open each database, I don't see the warning bar appear, so I assume it's something to do with the VBA code I'm using:
Dim db2 As Variant
Set db2 = CreateObject("Access.Application")
db2.OpenCurrentDatabase "NewDb.accdb"
db2.DoCmd.OpenForm "_View"
db2.DoCmd.OpenForm "_Home"
db2.UserControl = True
推荐答案
在调用 OpenCurrentDatabase
时包括 NewDb.accdb
的完整路径.我认为您需要与第一个数据库 (db1) 相同的文件夹.CurrentProject.Path
会给你那个文件夹的完整路径...
Include the full path to NewDb.accdb
when you call OpenCurrentDatabase
. I think you want the same folder as the first database (db1). CurrentProject.Path
will give you the full path of that folder ...
db2.OpenCurrentDatabase CurrentProject.Path & "\NewDb.accdb"
这篇关于使用 VBA 打开时,如何允许数据库运行 activex 内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!