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


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
 
Ad

Advertisements

B

Bob Phillips

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
 
Ad

Advertisements

M

MikeZz

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top