+ Reply to Thread
Results 1 to 3 of 3

When programmaticaly remove/replace Code Modules doesn't work

  1. #1
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    When programmaticaly remove/replace Code Modules doesn't work

    I've spent endless time on removing/replacing Code Modules in order to find out what triggers works versus doesn't work. My implementation in Code Module Management Workbook covers:
    • Cleanup, Export, Import, Remove, Transfer, and Synchronize for any number of Code Modules via a user interface.
    • Closes any target Workbook opened prior opening CoMMa.xlsm and re-opening it by preventing any macro is executed. That is because once any procedure had been executed the removal of a module will not take place before the procedure which removed the module has finished. A subsequent import considers the module still existing and provides a numeric suffix to make its name unique.
    • When the opened Workbook's VBA Project is password protected, VBE has to be opened manually in order to provide access to the Code Modules. This is possible after open and before selection.
    • Data Modules (i.e. the code in 'ThisWorkbbok' and any Worksheet) can be replaced just as any other module.
    • With Synchronize and Transfer a Worksheet yet not existing in the target Workbook is added (without creating any back-links!)
    • When Synchronize with the option Changed Only is selected, any UserForm is included in the list of selected Code Modules by default, because there is no way to obviate a design change.
    • Undo when the wrong target Workbook had been selected accidentially

    For those heading for their own implementation of a Code Module Managment means the following two key procedures may be of interest.
    The first one can be copied from the Test-Workbook CoMod.xlsm).
    The function CoMReplaceLbL in the Class Module clsCoMods replaces a Code Module in a target Workbook line by line by one with the same name whereby the source for the new code may be provided either through an export file (ends with .bas or .cls) or through a named Code Module in a source Workbook.
    The function returns a vbNullString or a short error message. It is well tested (and so you can do as well) by the above Test-Workbook.
    When the function is copied to your own project, please notice that Trust access to the VBA project object model and a Reference to Microsof Visual Basic for Applications Extensibiltiy 5.3 is required.
    With the function incorporated in a VBA project the project may update its own code (excluding the Code Module the function CoMReplaceLbL resides in).

    The second is a procedure which copies a Worksheet from a source Workbook to a target Workbook without any back-links to the source Workbook:
    Please Login or Register  to view this content.
    Last edited by Warbe; 12-21-2015 at 06:22 PM. Reason: updated according to up-to-date implementation

  2. #2
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187

    Re: When programmaticaly remove/replace Code Modules doesn't work

    Warbe,
    your post is interesting. Is there a question or problem with which you need help?


    click on the * Add Reputation if this was useful or entertaining.

  3. #3
    Registered User
    Join Date
    08-22-2011
    Location
    Berlin
    MS-Off Ver
    Excel 2010
    Posts
    51

    Re: When programmaticaly remove/replace Code Modules doesn't work

    Thanks for the question. My primary intention was to share my experience and last but not least the result of my effort which had come to meanwhile more than 100 hours.

+ 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. [SOLVED] Why doesn't this work? - Replace function
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2014, 01:57 AM
  2. Remove all code and modules from the active workbook
    By dasvas in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 02-09-2011, 11:26 PM
  3. VBA validation doesn't work in modules
    By adds007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-25-2010, 03:22 PM
  4. Excel bug: forcing autoformatting, find/replace doesn't work
    By QuantumPion in forum Excel General
    Replies: 2
    Last Post: 06-24-2008, 04:39 PM
  5. [SOLVED] Code to search and replace info on modules
    By Brett Smith in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2006, 05:10 PM
  6. [SOLVED] Find and Replace dialog box in VBA doesn't work suddenly
    By Leung in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-18-2005, 03:07 AM
  7. [SOLVED] Find and Replace code in Sheet modules
    By Jon in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-29-2005, 07:06 PM

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