ms-access-2007 - 如果“数字签名”项未出现在“工具”菜单中,我如何向 VBA Access 项目添加证书?

标签 ms-access-2007 ms-access-2010 digital-certificate

我正在尝试让 Access 2000 数据库在 Access 2010 运行时中运行,并删除有关文件不受信任的警告对话框。我做了一些研究并发现了 SelfCert.exe 程序。 This is a good tutorial on certificates. And this, too.甚至 Microsoft 都有针对 Access 2000 的说明,指示该菜单项应该存在。但是,我在 Access 2000 VBA IDE 中的工具菜单没有数字签名菜单项。更糟糕的是,当我右键单击菜单栏以自定义“工具”菜单时,我确实在自定义列表中看到了 Digital Signature... 项。当我单击并拖动以将其添加到“工具”菜单时,它无视我的命令。多么固执!如果我单击并将其他任何东西拖到“工具”菜单,它就像一个魅力。什么?!

如何安装该菜单项?或者,更好的是,当我从 Access 2010 运行时打开数据库时,如何让我的数据库不显示安全警告?

I cannot add the Digital Signature... item to the Tools menu

最佳答案

经过一些更重要的研究,我找到了第二个问题的答案,这正是我想要得到的最终答案。在 Access 2010 运行时中打开 Access 2000 数据库时,如何摆脱潜在的安全问题对话框?

Microsoft Access Security Notice

基本上,您需要将数据库添加到受信任位置列表中。 Access 2010 运行时不提供此功能的 UI,因此您必须以编程方式执行此操作。本网站提供代码:Utter Access Add Trusted Location

针对这种情况下的具体需求,我修改了它。在 Access 2010 运行时中运行 Access 2000 数据库。您将需要根据注册表设置为其他版本的运行时修改它。另外,我读到这在 Windows 8 中不起作用。但我还发现您不需要管理权限来运行此代码,因为它只修改注册表中的 HKEY_CURRENT_USER 配置单元,当前用户可以完全访问该配置单元。

Public Function AddTrustedLocation()
On Error GoTo err_proc
'WARNING:  THIS CODE MODIFIES THE REGISTRY
'You do not need administrator privileges
'since it only affects the HK_CURRENT_USER hive
'sets registry key for 'trusted location'

Dim intLocns As Integer
Dim i As Integer
Dim intNotUsed As Integer
Dim strLnKey As String
Dim reg As Object
Dim strPath As String
Dim strTitle As String

strTitle = "Add Trusted Location"
Set reg = CreateObject("wscript.shell")
strPath = CurrentProject.path

'Specify the registry trusted locations path for the Access 2010 runtime
strLnKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Access\Security\Trusted Locations\Location"

On Error GoTo err_proc0
'find top of range of trusted locations references in registry
For i = 999 To 0 Step -1
    reg.RegRead strLnKey & i & "\Path"
    GoTo chckRegPths        'Reg.RegRead successful, location exists > check for path in all locations 0 - i.
checknext:
Next
MsgBox "Unexpected Error - No Registry Locations found", vbExclamation
    GoTo exit_proc

chckRegPths:
    'Check if Currentdb path already a trusted location
    'reg.RegRead fails before intlocns = i then the registry location is unused and
    'will be used for new trusted location if path not already in registy

    On Error GoTo err_proc1:
    For intLocns = 1 To i
        reg.RegRead strLnKey & intLocns & "\Path"
        'If Path already in registry -> exit
        If InStr(1, reg.RegRead(strLnKey & intLocns & "\Path"), strPath) = 1 Then GoTo exit_proc
NextLocn:
    Next

    If intLocns = 999 Then
        MsgBox "Location count exceeded - unable to write trusted location to registry", vbInformation, strTitle
        GoTo exit_proc
    End If
    'if no unused location found then set new location for path
    If intNotUsed = 0 Then intNotUsed = i + 1

    'Write Trusted Location regstry key to unused location in registry
    On Error GoTo err_proc:
    strLnKey = strLnKey & intNotUsed & "\"
    reg.RegWrite strLnKey & "AllowSubfolders", 1, "REG_DWORD"
    reg.RegWrite strLnKey & "Date", Now(), "REG_SZ"
    reg.RegWrite strLnKey & "Description", Application.CurrentProject.Name, "REG_SZ"
    reg.RegWrite strLnKey & "Path", strPath & "\", "REG_SZ"

exit_proc:
      Set reg = Nothing
      Exit Function

err_proc0:
      Resume checknext

err_proc1:
      If intNotUsed = 0 Then intNotUsed = intLocns
      Resume NextLocn

err_proc:
      MsgBox Err.Description, , strTitle
      Resume exit_proc

End Function

我将此函数添加到 AutoExec 宏中。当用户首次登录时,他们会收到安全通知;但是,只要文档保留在它首次运行时所在的受信任位置,它就永远不会再次出现。呜呼!

关于ms-access-2007 - 如果“数字签名”项未出现在“工具”菜单中,我如何向 VBA Access 项目添加证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17409158/

相关文章:

c# - 如何使用 C# 在运行时在 MS Access 中创建存储查询

regex - 在 MS Access 2010 中使用正则表达式替换列

sql - Access 2010 - 查询以使用 Union All 和 Sum Iif 在多个表中生成特定事件的总计数/总和

clickonce - 如何将 DigiCert EV 证书应用于 ClickOnce 应用程序

ms-access - 使用 VBA 将是/否字段的显示控制属性更改为复选框

ms-access - 如何在Access中链接表格? (在它们之间传递值)

php - 使用 PHP 对文档进行数字签名

java - 使用java代码将证书添加到 keystore

ms-access - MS Access 2007 用于各种形式的按钮的公共(public)功能

database - 在 Access 2010 数据库中自动执行查询