'supprimer *tout* le code d'un classeur
'copier ce code dans un module standard d'un autre classeur que celui
'dont vous voulez supprimer toutes les macros et l'exécuter après avoir
'rendu actif le classeur dont les macros doivent être supprimées
'Bill Manville, mpep
Sub RemoveMacros()
Dim O As Object
For Each O In ActiveWorkbook.Sheets
If TypeName(O) = "Worksheet" Then
Select Case O.Type
Case xlExcel4MacroSheet, xlExcel4IntlMacroSheet
Application.DisplayAlerts = False
MsgBox "Macro sheet " & O.Name
O.Delete
Application.DisplayAlerts = True
End Select
ElseIf TypeName(O) = "Module" Then
Application.DisplayAlerts = False
MsgBox "Module " & O.Name
O.Delete
Application.DisplayAlerts = True
End If
Next
If Val(Application.Version) >= 8 Then
With ActiveWorkbook.VBProject
For Each O In .VBComponents
Select Case O.Type
Case 1, 2 ' standard or class module
MsgBox "Module " & O.Name
.VBComponents.Remove O
Case Else ' form or document
With O.CodeModule
If .CountOfLines > 0 Then
MsgBox "Module behind " & O.Name
.DeleteLines 1, .CountOfLines
End If
End With
End Select
Next
End With
End If
For Each O In ActiveWorkbook.Names 'noms dans le classeur
Select Case O.MacroType
Case xlFunction, xlCommand
MsgBox "Name " & O.Name
O.Delete
End Select
Next
End Sub