VBA Ref: Is there a way to check if "Trust access to VBA project object model" option is checked using VBA?

gifariz

Board Regular
Joined
May 2, 2021
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I made a code to auto-update VBA library references using Ms VBA Extensibility library, so that user doesn't need to add/remove the required/incompatible references by themselves in VBE.
Apparently it needs permission from user's PC by checking the "Trust access to VBA project model", so I currently made message box at workbook open asking user to do this setting once.
But I want to show this message only if the "Trust access to VBA project object model" option is still not selected. Is there a way to check whether this setting has been applied using VBA?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Do you mean something like this?

VBA Code:
Dim VBA_is_Trusted As Boolean
On Error Resume Next
VBA_is_Trusted = (Application.VBE.VBProjects.Count) > 0
debug.print VBA_is_Trusted
On Error GoTo 0

If it is not trusted, the calculation produces an error. If trusted, projects should be found.

My apologies for any quirks, English is not my native language. "So I blame Google translate for all my goofs." :devilish:
 
Upvote 1
Solution
Do you mean something like this?

VBA Code:
Dim VBA_is_Trusted As Boolean
On Error Resume Next
VBA_is_Trusted = (Application.VBE.VBProjects.Count) > 0
debug.print VBA_is_Trusted
On Error GoTo 0

If it is not trusted, the calculation produces an error. If trusted, projects should be found.

My apologies for any quirks, English is not my native language. "So I blame Google translate for all my goofs." :devilish:
oh yes right! I can just use some error handling and prompt that message when there is error running the VBE library. Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top