Enable Excel’s ‘Trust access to the VBA project object model’

It is easy to enable the checkbox in the options screen. The option can also be set via a registry entry (or two). To register a change in the registry, Excel must be restarted, but ALSO it is important to note that when Excel exits, it resets this flag. Excel cannot be running therefore. This means we need a few ingredients when we are programming a solution.

First check if Excel is running

  • is it 64 or 32bit as it affects what registry entries could exist.

Next set the registry entries

If the user does not need ton know if a setting will be successful , then use the “set it and hope for the best” strategy.

has been reset and it will fail anyways – then just set the 2 registry entries. Set the DWORD ‘AccessVBOM’ = 1 to trust.

Here are the two registry entries. In short set this one to 1 and the 2nd reg entry item if it exists.

  • HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Security\AccessVBOM
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Office\16.0\Excel\Security\AccessVBOM