How to check from .net code whether \"Trust access to the VBA project object model\" is enabled or not for an Excel application?
Manually I
This worked for me
Function VBATrusted() As Boolean
On Error Resume Next
VBATrusted = (Application.VBE.VBProjects.Count) > 0
End Function
Private Sub Workbook_Open()
If Not VBATrusted() Then
MsgBox "No Access to VB Project" & vbLf & _
"Please allow access in Trusted Sources" & vbLf & _
"File > Options > Trust Center > Trust Center Settings > Macro Settings > Trust Access..."
End If
End Sub
Source https://www.mrexcel.com/forum/excel-questions/659774-checking-if-trust-access-visual-basic-project-ticked.html