I'm writing a macro in vba (in excel) that takes in a workbook (with old macro code) and replaces certain modules in its vbaproject with more up to date versions (the newer versions are contained within the vba project of the macro I'm writing). The approach I was taking was to apply the following algorithm to each module that needed to be updated:
1. remove the old version
2. insert the new version
Step 1 works great using the remove method of the VBComponents collection. However, there is no opposite to the remove method (ie. add). Istead you can add a blank module or import one from text, but not copy one from another vbaproject. I'd like to advoid writing to disc (which would happen if I exported and then imported the macro.). Is there a way to directly add an existing module (VBComponent) to the VBComponents collection? Is there a better approach to this then what I've listed.
-Venkman
1. remove the old version
2. insert the new version
Step 1 works great using the remove method of the VBComponents collection. However, there is no opposite to the remove method (ie. add). Istead you can add a blank module or import one from text, but not copy one from another vbaproject. I'd like to advoid writing to disc (which would happen if I exported and then imported the macro.). Is there a way to directly add an existing module (VBComponent) to the VBComponents collection? Is there a better approach to this then what I've listed.
-Venkman