Reputation: 191
I am currently trying to programmatically enable access to the VBA object model using macros, but I simply do not understand the answers that I have found through Google.
As such I decided to try using keyboard shorcuts. For example, in my language if I press:
Alt -> F -> I -> C -> TAB -> T -> I -> I -> I -> TAB -> V
Then I have successfully enabled the setting to trust the VBA project model.
Is this approach completely idiotic?
Is there an easier way to enable the setting with actual coding rather than what I am trying to do here (I can see cases where my method would likely unreliable)?
And if my idea isn't as bad as it looks, then is there a way to carry it out?
Sites visited:
http://wellsr.com/vba/2017/excel/macro-to-enable-trust-access-to-the-VBA-project-object-model/ (Understandable, but too unreliable)
https://blogs.msdn.microsoft.com/cristib/2012/02/29/vba-how-to-programmatically-enable-access-to-the-vba-object-model-using-macros/ (Might as well be gibberish to me)
Upvotes: 1
Views: 237
Reputation: 7894
This is highly discouraged. The whole idea behind trusting option is requiring user permission. Imagine how "secure" it would be if every macro could automatically trust itself.
Edit: though it may be possible with mentioned SendKeys
method, you will still need a click from the user to enable macros, i.e. when they open your file.
Upvotes: 1