Macro to delete Macros?

  • Thread starter Thread starter Bob Vance
  • Start date Start date
B

Bob Vance

--
Is there a code that I can put in a macro to delete all macros in a book at
a certain date?


Thanks in advance.........Bob Vance
 
Hi Bob
Sub TestDate()
If Date = "23/06/2004" Then
DeleteAllMacros
End If
End Sub

Sub DeleteAllMacros()
Dim Composantvbe As Object
With ActiveWorkbook.VBProject
For Each Composantvbe In .VBComponents
If Composantvbe.Type = 100 Then
With Composantvbe.CodeModule
.DeleteLines 1, .CountOfLines
.CodePane.Window.Close
End With
Else: .VBComponents.Remove Composantvbe
End If
Next Composantvbe
End With
End Sub

HTH
Cordially
Pascal
 
Back
Top