How can I verify if "Trust access to visual basic project" is chec

  • Thread starter Thread starter MikeZz
  • Start date Start date
M

MikeZz

I have a macro that requires this option to be checked.
"Trust access to visual basic project"

I know the only way to check the box is either manually or through Send Keys.
Is there a way through some property to see if it is checked or unchecked?


If there is, I can shut the macro down prior to it crashing with a dialog
box telling the user what to do to enable all the features.

This would really help!

Thanks,
MikeZz
 
Function VBAIsTrusted() As Boolean
Dim mpVBC As Object
Dim mpAlerts As Boolean
mpAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
On Error Resume Next
Set mpVBC = ThisWorkbook.VBProject.VBComponents.Item(1)
On Error GoTo 0
Application.DisplayAlerts = mpAlerts
VBAIsTrusted = Not mpVBC Is Nothing
End Function
 
Perfect! This will be a great help Bob,

Bob Phillips said:
Function VBAIsTrusted() As Boolean
Dim mpVBC As Object
Dim mpAlerts As Boolean
mpAlerts = Application.DisplayAlerts
Application.DisplayAlerts = False
On Error Resume Next
Set mpVBC = ThisWorkbook.VBProject.VBComponents.Item(1)
On Error GoTo 0
Application.DisplayAlerts = mpAlerts
VBAIsTrusted = Not mpVBC Is Nothing
End Function



--
__________________________________
HTH

Bob
 
Back
Top