How to Determine if your Solution is in Disabled Mode

I was asked this question the other day and thought it's worth answering right away, and in public': "How can I programmatically determine that my solution is in disabled mode in Access 2007?"

Well, this is very simple: by checking the value of the IsTrusted property off of the CurrentProject object. If it is set to true, the solution is enabled. If it is false, it is in disabled mode.

Notice that you can use this in a simple standalone or embedded macro to determine if you want to try to run some VBA code or not. For example, in this macro you can simply tell the user to enable the solution:

Condition Action Arguments

Not [CurrentProject].[IsTrusted] MsgBox "Trust my solution before using!"
Not [CurrentProject].[IsTrusted] CloseDatabase
[CurrentProject].[IsTrusted] RunCode VBAStartup

9/19: Fixed typo "[CurrentProject.IsTrusted]" to "[CurrentProject].[IsTrusted]". Thanks for catching it, Andre.