Removal of modules
Hi
I can remove lines in CodeModule by using the following syntax
For I = 1 To 3
Application.VBE.SelectedVBComponent.CodeModule .DeleteLines (1), 1
Next
But actually I would like to remove the whole module, does anyone know how to do this, if posssible ?
Cheers
Karsten
I found the solution. If anyone else is interested.
set a reference to:
Microsoft Visual Basic for Application Extensibility.
And use the following code in a module.
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("Module2")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub
Cheers
|