PDA

View Full Version : Code to delete all modules



ferrugo
01-17-2009, 05:52 AM
hi everybody
Sorry about the bad english...

I need a code to delete all modules.

Example, i have 20 workbooks, then i want delete all modules that exists in thats workbooks :banghead: , so i want a code to do this for me. It is possible? I think is not, i tried several times but ?ot solve the question...

thanks....

Bob Phillips
01-17-2009, 07:23 AM
'----------------------------------------------------------------
Sub DeleteModules()
'----------------------------------------------------------------
Dim oVBMod As Object
Dim i As Long

With ActiveWorkbook.VBProject
For Each oVBMod In .vbcomponents
Select Case oVBMod.Type
Case 1: 'vbext_ct_StdModule
ActiveWorkbook.VBProject.vbcomponents.Remove oVBMod
End Select
Next oVBMod
End With

End Sub