Results 1 to 7 of 7

How to check if "Trust access to the VBA project object model" has been enabled on machine

Threaded View

welchs101 How to check if "Trust access... 05-17-2012, 06:47 AM
Andy Pope Re: How to check if "Trust... 05-17-2012, 08:03 AM
Air_Cooled_Nut Re: How to check if "Trust... 08-21-2012, 06:01 PM
redseujac Re: How to check if "Trust... 07-27-2013, 01:25 PM
Alf Re: How to check if "Trust... 05-17-2012, 08:06 AM
john456852 Re: How to check if "Trust... 07-27-2013, 01:46 PM
redseujac Re: How to check if "Trust... 07-30-2013, 11:48 AM
  1. #3
    Registered User
    Join Date
    10-26-2004
    Location
    Portland, Oregon
    MS-Off Ver
    Excel in Windows
    Posts
    49

    Re: How to check if "Trust access to the VBA project object model" has been enabled on mac

    Quote Originally Posted by Andy Pope View Post
    I don't think there is a property to test.
    Instead you can create your own function which uses error trapping.

    Function VBATrustedAccess() As Boolean
    '
        On Error Resume Next
        VBATrustedAccess = (Application.VBE.VBProjects.Count) > 0
        Exit Function
        
    End Function
    Sub Test()
    
        If VBATrustedAccess() Then
            MsgBox "Access Granted"
        Else
            MsgBox "No Access to VBA"
        End If
        
    End Sub
    Appears to work with limited testing.
    If the workbook that contains the code above is closed, then re-opened in the same Excel session (meaning don't Exit Excel) the check won't work. When I put it in my workbook Open event it worked the first time but when I closed the file and then re-opened it in the same Excel session the Workbook_Open event didn't even fire off!
    Private Sub Workbook_Open()
    
        If VBATrustedAccess() Then
            MsgBox "Access Granted"
        Else
            MsgBox "No Access to VBA"
        End If
    End Sub
    Excel 2010 in Windows 7
    Last edited by Air_Cooled_Nut; 08-21-2012 at 06:06 PM.
    ~Toby

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1