0

I have created a macro-enabled Excel workbook that requires users to have "Trust access to the VBA project object model" enabled in the Excel Macro Security settings.

macro security settings

I forgot I had already done this, and my coworker got stuck on (not responding) when trying to run the macro.

This window can also be brought up with this code:

Application.CommandBars.ExecuteMso("MacroSecurity")

Can I programmatically determine the value of this checkbox with VBA? I'd like to be able to check whether a user has this feature enabled before allowing them to run the macro that could potentially hang up their machine.

  • 2
    https://stackoverflow.com/questions/5300770/how-to-check-from-net-code-whether-trust-access-to-the-vba-project-object-mode For .NET but same basic principles apply. – Tim Williams May 25 '21 at 21:45
  • 1
    Does this answer your question? [How to check from .net code whether "Trust access to the VBA project object model" is enabled or not for an Excel application?](https://stackoverflow.com/questions/5300770/how-to-check-from-net-code-whether-trust-access-to-the-vba-project-object-mode) – HackSlash May 25 '21 at 21:53

1 Answers1

0

Thanks, y'all

Private Function VBATrusted() As Boolean
    On Error Resume Next
    VBATrusted = (Application.VBE.CommandBars.Count) > 0
End Function