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!

Editing excel modules from VB 1

Status
Not open for further replies.

johnbrewster

Programmer
Mar 20, 2003
2
GB
I am formatting excel workbooks from a VB app and I need to perform a search and replace on one of the macro/modules in the worksheet. I cannot find the way to call the module/macro collection that lets me edit them.
 
Hi
I've never done this so can't comment on it's usability and I don't know if it's accessible from VB but this site MAY be of some use to you!


;-) If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
You need a reference to VBA Extensibility library.

Here an example how to add a line to a "Module1"
[tt]Dim cMod As VBComponent
Set cMod = ThisWorkbook.VBProject.VBComponents.Item("Module1")
With cMod.CodeModule
.InsertLines .CountOfLines + 1, "' new line"
End With[/tt]

You can use ProcStartLine, ProcCountLines properties of CodeModule object to find procedure, InsertLines, RepLaceLines, DeleteLine to edit code.
See VBA help for details.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top