Tabellenblatt einfügen abfangen Vorlage kopieren...[ZIP, 70 KB]
' Code in "DieseArbeitsmappe"
Option Explicit
Dim AppObject As New clsDatei
Private Sub Workbook_Open()
Set AppObject.AppLiCa = Application
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Set AppObject.AppLiCa = Nothing
End Sub
' Code in ein Klassenmodul mit Namen "clsDatei"
Option Explicit
Public WithEvents AppLiCa As Application
Private Sub AppLiCa_WorkBookNewSheet(ByVal Wb As Workbook, _
ByVal Sh As Object)
On Error GoTo Fin
With AppLiCa
.ScreenUpdating = False
.DisplayAlerts = False
End With
With Wb
.Worksheets(.Worksheets.Count).Delete
ThisWorkbook.Worksheets("Vorlage").Copy _
After:=.Worksheets(Worksheets.Count)
.Worksheets(Worksheets.Count).Name = "New" & .Worksheets.Count
End With
Fin:
With AppLiCa
.ScreenUpdating = True
.DisplayAlerts = True
End With
If Err.Number <> 0 Then MsgBox "Fehler: " & _
Err.Number & " " & Err.Description
End Sub