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,
 
Did you set the reference to the VBE Extensibility as explained in that
link?

RBS
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top