+ Reply to Thread
Results 1 to 7 of 7

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

  1. #1
    Forum Contributor
    Join Date
    12-01-2007
    Location
    USA-North Carolina
    MS-Off Ver
    MS Office 2016
    Posts
    2,666

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

    I have a macro where i copy code from the vba project area to a new workbook. In order to do this i have to have enabled the

    "Trust access to the VBA project object model"

    I was wondering if there was a way to test to see if this was indeed disabled so i could let the user know they need to enable it to have program run as it should.

    Any ideas?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,438

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

    I don't think there is a property to test.
    Instead you can create your own function which uses error trapping.

    Please Login or Register  to view this content.
    Appears to work with limited testing.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

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

    Like this perhaps?

    http://stackoverflow.com/questions/5...ct-object-mode

    Alf

  4. #4
    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.

    Please Login or Register  to view this content.
    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!
    Please Login or Register  to view this content.
    Excel 2010 in Windows 7
    Last edited by Air_Cooled_Nut; 08-21-2012 at 06:06 PM.
    ~Toby

  5. #5
    Registered User
    Join Date
    04-02-2011
    Location
    Ypres, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    19

    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.

    Please Login or Register  to view this content.
    Appears to work with limited testing.
    I don't quite understand how it's possible to let this work.

    When put in the Workbook_Open event, there's naturally no problem if "Trust access to the VBA project object model" is enabled in Excel, but if it's not enabled, the VBA code can not even be executed from Workbook_Open, so no message box will be shown and in my case my Workbook cannot be opened and Excel freezes.

    I would be grateful if you could help me further and explain me how I could definitely have a message shown if "Trust access..." is not enabled. It's a fact the VBA code can not be run if "Trust access..." is not enabled.

    Jacques
    Jacques

  6. #6
    Forum Contributor
    Join Date
    08-22-2012
    Location
    nj, us
    MS-Off Ver
    Excel 2010
    Posts
    163

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

    pls post a sample

  7. #7
    Registered User
    Join Date
    04-02-2011
    Location
    Ypres, Belgium
    MS-Off Ver
    Excel 2010
    Posts
    19

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

    Quote Originally Posted by john456852 View Post
    pls post a sample
    Not necessary. It's solved now. The code above is working. There were other entries in the Workbook _Open event preventing the code from working (properly). I managed things with an "If-Then-Else" construct.

+ Reply to Thread

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