ist es möglich, per VBA ein bestimmtes Sub oder sogar ein Modul aus dem VBA Projekt zu entfernen?
vielen Dank & Gruß
Chris
Option Explicit
Private Sub Workbook_Open()
Dim intIndex As Integer, intLine As Integer, intStartLine As Integer, intEndLine As Integer
If ThisWorkbook.CustomDocumentProperties.Count = 0 Then
ThisWorkbook.CustomDocumentProperties.Add Name:="Nr", LinkToContent:=False, Type:=msoPropertyTypeNumber, Value:=0
End If
ThisWorkbook.CustomDocumentProperties("Nr") = ThisWorkbook.CustomDocumentProperties("Nr") + 1
ThisWorkbook.SaveAs Filename:="Rechnung" & ThisWorkbook.CustomDocumentProperties("Nr")
With ThisWorkbook.VBProject
For intIndex = 1 To .VBComponents.Count
With .VBComponents(intIndex).CodeModule
For intLine = 1 To .CountOfLines
If .ProcOfLine(intLine, 0) = "Private Sub Workbook_Open()" Then
If intStartLine = 0 Then
intStartLine = intLine
Else
intEndLine = intLine
End If
End If
Next
If intStartLine <> 0 Then
.DeleteLines intStartLine, intEndLine - intStartLine + 1
Exit For
End If
End With
Next
End With
End Sub