Gruppe
VBE
Problem
Ein Arbeitsblatt soll als neue Arbeitsmappe ohne den Ereigniscode, die Schaltfläche und die Formel gespeichert werden.
ClassModule: Tabelle3
Private Sub CommandButton1_Click()
Worksheets("Tabelle1").Copy
ActiveSheet.OLEObjects.Delete
With ActiveSheet.UsedRange
.Value = .Value
End With
With ActiveSheet.Parent.VBProject.VBComponents(ActiveSheet.CodeName).CodeModule
.DeleteLines 1, .CountOfLines
End With
On Error GoTo ERRORHANDLER
ActiveWorkbook.SaveAs Range("B1").Value & "\test.xls"
Exit Sub
ERRORHANDLER:
MsgBox "Die Datei konnte nicht gespeichert werden!"
End Sub