vbComponents.Remove on Active Module

  • I'm trying to automate code changes across a few dozen Excel files, but am having trouble (vbComponents).Remove-ing one of the modules. My only guess as to why this may be happening is because one of the macros in that module is being called on Workbook_Open. Is there any way to:

    1) Disable all macros when opening a project (via VBA) but still allowing access to the code for .Remove/.Import

    2) Force all running/active macros to end

    3) Force a .Remove even on running/active modules

    Thanks in advance.


  • To anyone interested:

    I've found a solution to this problem. It's not the most elegant, but it does work.

    I have an Excel file (UTILITY) that opens a series of files (PROJECT) one by one. The PROJECT files all contain two macros (each in separate modules):


    Sub Refresh_Update_Code
    '.Remove and .Import Module2
    End Sub


    Sub Refresh_All_Modules
    '.Remove and .Import all modules (except Module2)
    End Sub

    The UTILITY file calls both of these macros in turn, first updating the update module, than updating everything else.

    If anyone knows of a better way, please post.


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!