Delete a module in VBA?

  • Thread starter Thread starter Philip Reece-Heal
  • Start date Start date
P

Philip Reece-Heal

I use an Excel template with a lot of modules to produce a particular type
of report and when I have completed the workbook, I send it to others but do
not wish to include all the VBA modules. Therefore, in VBA, I manually
delete each module.

Is there a way to do this in VBA code?

Anybody got any good suggestions?
Look forward to response
Philip
 
From Chip
Deleting A Module From A Workbook

The procedure below will delete the module named "NewModule" from
ThisWorkbook.

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

You cannot delete the ThisWorkbook code module, or a sheet code module, or a
chart code module.
 
Back
Top