ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Modules (https://www.excelbanter.com/excel-programming/315732-modules.html)

Rich

Modules
 
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

ehntd[_6_]

Modules
 

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

--
ehnt
-----------------------------------------------------------------------
ehntd's Profile: http://www.excelforum.com/member.php...fo&userid=1586
View this thread: http://www.excelforum.com/showthread.php?threadid=27515



All times are GMT +1. The time now is 10:21 PM.

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