Count
12.05.2009 12:01:54
Stefan
kann mir jemand sagen warum das Makro bereits bei
For n = ThisWorkbook.VBProject.vbComponents.Count To 1 Step -1
aussteigt?
Gruß,
Stefan
Option Explicit
Sub Alles_löschen()
Call Lösche_Module
Call Lösche_Userformen
Call Lösche_Ereignisprozeduren
End Sub
Sub Lösche_Module()
Rem Löscht Module:
For n = ThisWorkbook.VBProject.vbComponents.Count To 1 Step -1
If ThisWorkbook.VBProject.vbComponents(n).Type = 1 Then
ThisWorkbook.VBProject.vbComponents(n).Collection.Remove _
ThisWorkbook.VBProject.vbComponents(n)
End If
Next
End Sub
Sub Lösche_Userformen()
Rem Löscht Userforms:
For n = ThisWorkbook.VBProject.vbComponents.Count To 1 Step -1
If ThisWorkbook.VBProject.vbComponents(n).Type = 3 Then
ThisWorkbook.VBProject.vbComponents(n).Collection.Remove _
ThisWorkbook.VBProject.vbComponents(n)
End If
Next
End Sub
Sub Lösche_Ereignisprozeduren()
Rem Löscht Ereignisprozeduren:
For n = ThisWorkbook.VBProject.vbComponents.Count To 1 Step -1
For i = 1 To ThisWorkbook.VBProject.vbComponents(n).CodeModule.CountOfLines
If ThisWorkbook.VBProject.vbComponents(n).Type 1 And _
ThisWorkbook.VBProject.vbComponents(n).Type 3 Then _
ThisWorkbook.VBProject.vbComponents(n).CodeModule.DeleteLines 1
Next
Next
End Sub