+ Reply to Thread
Results 1 to 13 of 13

VBA Editor opens all user Add-In modules by default

  1. #1
    Registered User
    Join Date
    12-10-2012
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    VBA Editor opens all user Add-In modules by default

    Whenever I open the VBA Editor after a fresh start of Excel (e.g. Alt+F11), it opens the modules for any user defined Add-In by default. Is this standard behavior? And is there a way to avoid that?

    If that's of interest: These "user defined" Add-Ins are located in my personal folders.

    Thanks for any input!
    Ben

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Editor opens all user Add-In modules by default

    Hi Ben,

    To avoid the above situation, you need to use the "Workbook_Open" event to install whatever Add-Ins are appropriate to the workbook you're opening, and then use the "Workbook_BeforeClose" event to uninstall those Add-Ins when your workbook is being closed.

    E.g.

    Please Login or Register  to view this content.


    The above code should be entered in the "ThisWorkbook" VBA CodeModule.

    Hope this helps - please let me know how you get on with it.

    Regards,

    Greg M

  3. #3
    Registered User
    Join Date
    12-10-2012
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: VBA Editor opens all user Add-In modules by default

    Thank you Greg, but I probably didn't make my issue sufficiently clear.
    I do want these Add-Ins to be loaded by default, i.e. their functionality available in every notebook I open.

    The issue I have is only with the annoying fact that the windows of all these modules and even the PERSONAL.XLSB module are open when I open the VBA editor. So I have about 15 or 20 opened windows in the editor, and have to close/minimize one by one by hand to get to the one I want to edit. No matter whether I close them all, fold the project tree to the highest level ... whenever I reopen Excel and then the VBA editor, all module windows will be open again.

    If this were unalterable standard behavior there'd probably be more threads like this - so I assume it isn't and there is a way around it. I just can't see it.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Editor opens all user Add-In modules by default

    Hi again,

    In the VBA Editor, create a Reference (Tools >> References...) to "Microsoft Visual Basic for Applications Extensibility n.n" and then insert the following code into the "ThisWorkbook" VBA CodeModule of a new workbook:


    Please Login or Register  to view this content.


    The above routine will close all CodeModule and Form windows in the VB Editor.

    To fully achieve what you're looking for you will need to save the above workbook in the folder specified in the StartUp or Alternate StartUp File Location, so that it is opened every time Excel starts.

    Hope this helps - please let me know how you get on with it.

    Regards,

    Greg M

  5. #5
    Registered User
    Join Date
    12-10-2012
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: VBA Editor opens all user Add-In modules by default

    Thank you Greg. I followed your suggestion, but ran into two problems.
    Referencing "Microsoft Visual Basic for Applications Extensibility n.n" lead to an error/warning that this conflicts with other active references/modules (?) - I cannot reproduce the message. The other active references are
    • Visual Basic for Applications
    • Microsoft Excel 14.0 Object Library
    • OLE Automation
    • Microsoft Windows 14.0 Object Library
    Should I expect any real conflicts here?

    Anyway, with the reference active, I now get (translated)
    Error 1004
    The programmatic access to the Visual Basic Project is not safe
    It points to the code line
    Please Login or Register  to view this content.
    I have no experience with these things, could you help me out once more?

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Editor opens all user Add-In modules by default

    Hi again,

    I'm not sure why you're getting the "this conflicts with other active references/modules" message - it's not something I've ever encountered.

    If the other message you're getting is "The programmatic access to the Visual Basic Project is not trusted" then the way to overcome that is as follows:

    In the main Excel window (i.e. not the Visual Basic Editor window),

    Click on the "File" tab in the Ribbon
    Click on the "Options" icon in the left-hand column
    Click on the "Trust Center" option in the left-hand column

    Click on the "Trust Center Settings..." button

    Click on the "Macro Settings" option in the left-hand column

    Tick the "Trust access to the VBA project object model
    Click on "OK"

    Click on "OK"

    Hope this helps - please let me know how you get on with it.

    Regards,

    Greg M

  7. #7
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA Editor opens all user Add-In modules by default

    Perhaps you may try Tools-Options-General-'Collapse Proj. hides Windows' option. It will allow you to close the windows quickly at least.

  8. #8
    Registered User
    Join Date
    12-10-2012
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: VBA Editor opens all user Add-In modules by default

    @ Greg: Apparently, our admins won't allow me to access that option, it's greyed out.

    @Izandol: I have this option selected, and it does work. But while Excel does remember the state of the project (collapsed or not collapsed), it only closes the respective windows after I unfold and recollapse the project. Since I usually have just one module per project, it doesn't make much of a difference to closing the windows individually.

    Thanks to both of you nonetheless!
    What I didn't understand yet: Is the behavior standard? Do your project modules and PERSONAL.XLSB open by default? I think there was a time when mine didn't, but I'm not certain.
    Last edited by benwin; 12-18-2013 at 03:13 AM.

  9. #9
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA Editor opens all user Add-In modules by default

    I think it is the default but, as you, I think this was not always the case.

  10. #10
    Registered User
    Join Date
    12-10-2012
    Location
    Munich, Germany
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: VBA Editor opens all user Add-In modules by default

    Thanks!

    Regards,
    Ben

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

    Re: VBA Editor opens all user Add-In modules by default

    If you password protect the projects of the add ins, I suspect this will override any default behaviour and prevent them from opening.

  12. #12
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: VBA Editor opens all user Add-In modules by default

    It seems that when you close the module windows and then save the workbook, the windows do not reopen automatically thereafter.

  13. #13
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641

    Re: VBA Editor opens all user Add-In modules by default

    Hi Ben,

    Thanks for taking the trouble to post your feedback - I guess your Admins have their own reasons for not making that option available.

    Best regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 10-16-2013, 07:17 AM
  2. [SOLVED] Open UserForm when workbook opens (and not the code editor)
    By GavJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2013, 02:12 AM
  3. [SOLVED] Macro now opens up VBA editor - not intended
    By excelnut1954 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-13-2006, 01:40 PM
  4. VB editor opens by magic
    By dallag in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2006, 09:30 AM
  5. Computer Lock opens up VB editor
    By Phaedrus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2005, 08:50 PM

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