Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automated module replacement

Status
Not open for further replies.

venkman

Programmer
Oct 9, 2001
467
US
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
 
nevermind, I tried a new method by copying the text from the code modules of each VBComponent. That seemed to work well.

-Venkman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top