0

I want to monitor my references.

But no matter what I use:

For Each objReference In VBE.ActiveVBProject.References
For Each objReference In ActiveDocument.VBProject.References
Set mytemplate = ActiveDocument.AttachedTemplate
For Each objReference In mytemplate.VBProject.References

I get the error 6068

Programmatic access to Office VBA project is denied, becuse the user has not set the "Trust access to the VBA project object model" check box.

But I cannot ask users to make changes in the Trust Center.

So my question is, can you give permission via VBA?

braX
  • 11,506
  • 5
  • 20
  • 33
R L
  • 55
  • 8
  • 1
    Does this answer your question? [Programmatic Access To Visual Basic Project Is Not Trusted](https://stackoverflow.com/questions/25638344/programmatic-access-to-visual-basic-project-is-not-trusted) – Jeremy Thompson Apr 17 '20 at 05:45

1 Answers1

0

You cannot give trusted access to the VBA project object model via code. Were that possible, virus/malware writers would have a field day.

macropod
  • 12,757
  • 2
  • 9
  • 21