View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Delete a module in VBA?

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.


--
Don Guillett
SalesAid Software

"Philip Reece-Heal" wrote in message
. ..
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