Remove Modules

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to build a code to remove excel vb module 1, module 2 and
module 3 that I have in my VBA project?

For instance I'm trying to remove module 1 after I execute the macro, I then
execute the macro in module 2 and remove module 2 ...

Thanks,
 
I'm trying to put the following code avalaible in the link u send me, but I
keep getting a compile error user-defined type not defined!

Sub DeleteModule()
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent

Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBComponents("Module1")
VBProj.VBComponents.Remove VBComp
End Sub

Can u help me?

Thanks,
 
You must have the Visual Basic for Applications Extensibility Libray referenced
under Tools>References.

Chip points this out at the site you were guided to.


Gord Dibben MS Excel MVP
 
Back
Top