ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete a module in VBA? (https://www.excelbanter.com/excel-programming/282362-delete-module-vba.html)

Philip Reece-Heal[_3_]

Delete a module in VBA?
 
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



Chip Pearson

Delete a module in VBA?
 
Phillip,

See www.cpearson.com/excel/vbe.htm for detail about working with VBProject
objects and code with code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"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





Don Guillett[_4_]

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






All times are GMT +1. The time now is 07:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com