Modules

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

Guest

I am trying to write a piece of VBA that takes a copy of a workbook, deletes
various sheets, deletes the module that is attached to the sheet and then
e-mails it to a list of recipients.

I have managed to acheive everything EXCEPT the deletion of the module. Can
anyone give me the code to delete "Module1" from my workbook using VBA.

Thanks,

Rich
 
Sub DeleteModule()
Dim VBComp As VBComponent
Set VBComp = ThisWorkbook.VBProject.VBComponents("NewModule")
ThisWorkbook.VBProject.VBComponents.Remove VBComp
End Sub



You need to have the Microsoft Visual Basic For Application
Extensibility library activated in your references
 

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