+ Reply to Thread
Results 1 to 21 of 21

Seeking knowledge on certain advanced options

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Lightbulb Seeking knowledge on certain advanced options

    I have a number of macro tools & calculators used by others. Most of the end users have little to no VBA knowledge.

    Is there any code which would:
    1. Check if the options listed below are enabled?
    2. Automatically enable these without the end users consent?
    3. If the last point is not possible then prompt the user to enable?


    for the following Excel options:
    • "Trust access to the VBA Project Object Model"
    • Developer tab (i.e. Show on Excel ribbon)

    (There were 1 or 2 other options I can't think of right now but these two were the main ones).
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Seeking knowledge on certain advanced options

    There is, to my knowledge, no way to show the developer tab via VBA.

    And there's no way to enable access to the VBA project programmatically -- it would be a massive security risk.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by shg View Post
    There is, to my knowledge, no way to show the developer tab via VBA.

    And there's no way to enable access to the VBA project programmatically -- it would be a massive security risk.
    Security implications understood.

    Well if I can't enable via code (question 2), do you know of a way of detecting the state of these options (question 1) so I can give the user a little MsgBox explaining what he/she needs to turn on?

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    I have a vague recollection of seeing this done before (albeit on a different feature - it was a specific VBA Tool Reference from memory). In the case I recall, the code detected if the feature wasn't enabled and displayed a form telling the user what box they needed to tick and then, to top it off, took the user right to the very option screen they needed to access! (It didn't auto-enable but I was impressed that it checked & held the end users hand right to the point where they had to manually enable!)

    But do you think I can find this code again now? No!
    Last edited by mc84excel; 02-07-2013 at 09:49 PM. Reason: clarify

  5. #5
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Seeking knowledge on certain advanced options

    You could hide all the worksheets but one and display a textbox or something that tells the user to reopen the file with macros enabled. Something like the attached file.

    edit: here's the code that I've put in the ThisWorkbook module:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Seeking knowledge on certain advanced options

    vbaproject access is set via a registry key which may or may not exist-if it doesn't then the default is untrusted access. you can either try and read that key or simply try and access a component of the vbproject and check for errors

    I'm not clear why you need the users to have the developer tab visible-why don't you use your own tab?
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by RHCPgergo View Post
    You could hide all the worksheets but one and display a textbox or something that tells the user to reopen the file with macros enabled.
    I appreciate your help. However this code isn't what I was looking for. (You are referring to the 'Force User to Enable Macros' code. I want to force options like VBA project).

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by JosephP View Post
    vbaproject access is set via a registry key which may or may not exist-if it doesn't then the default is untrusted access. you can either try and read that key or simply try and access a component of the vbproject and check for errors
    Both good ideas. I will look into reading registry keys.

    With the Developer Tab - because I have difficulty explaining to non-VBA users how to install Add-Ins. This helps eliminate one of the steps. (I am looking at creating an easy add-in installer - but that's a topic for another thread some day).

  9. #9
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by mc84excel View Post
    I appreciate your help. However this code isn't what I was looking for. (You are referring to the 'Force User to Enable Macros' code. I want to force options like VBA project).
    Sorry, my bad. Good luck with your project though.

  10. #10
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Seeking knowledge on certain advanced options

    Why do you want to do this? Requiring programmatic access is not good practice when distributing workbooks, it requires users to lower security settings, it can have issues with anti-virus software and code writing code is generally a hacky horrible way to do something that can usually be done more easily another way. Do you really need to write code at run time?

  11. #11
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Seeking knowledge on certain advanced options

    you don't have to be writing code at runtime to require access to the vbp

    regarding the developer tab that is not the only way to install add-ins and you could easily replicate any buttons from that tab on your own custom tab if required

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by JosephP
    you don't have to be writing code at runtime to require access to the vbp
    True, but it's still bad practice, that's the most common reason for needing access to it. Requiring access to the VBP is not a good thing due to security risks, it's one thing on your own machine, but quite another expecting users to lower their security settings to run a few macros.

    The better method would be to evaluate the approach and see if the same task can be achieved without programmatic access to the VBP

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Seeking knowledge on certain advanced options

    tell Rob Bovey that ;-)

    additionally macro viruses are not particularly common nowadays

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Seeking knowledge on certain advanced options

    Indeed, but distributing a workbook with the caveat "You'll need to lower your security to run this", hardly sounds appealing - and why bother when it's usually straightforward to do what needs doing without extensibility?

    Tell him what? That it's better to have an elegant solution that doesn't need access to the VBP over a PITA one that does?

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Seeking knowledge on certain advanced options

    that it's bad practice to ask users to lower their security. some of his add-ins have required that

    ime, if you need access to the vbp, you need it period.

  16. #16
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Seeking knowledge on certain advanced options

    That may be the case, there's obviously a place for code that aids the writing of code - but that isn't in the workbooks of normal users. There are plenty of really great add-ins out there that require access to the VBP for IDE development; but you wouldn't expect to find them installed on the machine of the average user, rather they're designed to be used by cody people who understand the implications of what they're doing as an aid to producing solutions for users that don't require vbp access.

    ime 90% of the users on forums asking about programmatic access to the VBP could achieve their aims more simply without it, 9 times out of 10 it's because the project wasn't planned properly in the first place and I've seen it wielded as an alternative to using classes too often.

    Anyway, are we hijacking a bit here, or at least going a bit off topic...?

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Seeking knowledge on certain advanced options

    true but since we don't know what the op is doing I don't think you can say that it is necessarily bad practice or unnecessary

    I reckon we're still on topic if meandering down some side trails ;-)

  18. #18
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    @ JosephP & Kyle123 - Interesting comments

  19. #19
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by JosephP View Post
    regarding the developer tab that is not the only way to install add-ins
    Agreed. One of my current projects is a 'no-brainer' XLAM installer for users with limited VBA knowledge.

  20. #20
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Would it be possible (preferably not by registry checking if possibly avoid) to determine whether a certain VBA Tools Reference is enabled and enable if not? (Or at least prompt the user to enable if not?)

  21. #21
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Seeking knowledge on certain advanced options

    Quote Originally Posted by Kyle123 View Post
    Why do you want to do this? Requiring programmatic access is not good practice when distributing workbooks...Do you really need to write code at run time?
    Please forgive my lack of VBA knowledge. I don't think I will need access to "Trust access to the VBA Project Object Model" after all.
    Last edited by mc84excel; 02-14-2013 at 10:24 PM. Reason: clarify what I don't need (still looking for solution to Tool References)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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