Hi there Eric,
Rather than search your code for one line, why not replace the entire
module? It would seem to me that would be a little easier. If you Export
the Module in question to a known location on your computer (I used my
desktop), you can use something like this ...
Sub ImportBAS()
Dim strBASpath As String
strBASpath = "C:\Documents and Settings\Rob\Desktop\Module1.bas"
Application.VBE.ActiveVBProject.VBComponents.Impor t strBASpath
End Sub
Obviously, change the 'strBASpath' to the path/name your Module .BAS file is
located.* Note that it will not overwrite any Modules that are currently in
the system by the same name. If you need to delete a Module, you would need
to add some code like this ...
Dim VBmod As Object
Set VBmod = ThisWorkbook.VBProject.VBComponents("Module1")
Application.VBE.ActiveVBProject.VBComponents.Remov e VBmod
*To Export your Module, right click the Modue | Export.., choose location,
Ok. Remember to SAVE YOUR WORK BEFORE YOU RUN ANY OF THIS CODE!
Adding/Deleting Modules can be very serious and you should have backups
already in place anytime you run procedures such as this.
--
Regards,
Zack Barresse, aka firefytr
"Eric" wrote in message
...
Hello,
I have a set of workbooks that all have a similar macro in them. Each of
these macros contains a string I need to change, but to change it manually
in each file is time prohibitive - 60+ files.
Given I already have one of these files open with a seperate macro, from
the
seperate macro, how do I access the module - say Module1, search for the
line that contains the text needing to be changed, change it and then
close
the file?
I already have the list of files and the loop to go through all of them. I
am just unclear on how to change the Module1/Macro text from another
macro.
Any ideas?
Thank you very much in advance.
Eric Pearce
|