Gruppe
VBE
Problem
Dieses Blatt wird in eine neue Arbeitsmappe kopiert, wobei auch Modul1 in die neue Arbeitsmappe übernommen wird.
StandardModule: Modul1
Sub MeinMakro()
MsgBox "Ich sollte kopiert werden!"
End Sub
StandardModule: Modul2
Sub Meldung()
MsgBox "Ich bin nur ein Platzhalter!"
End Sub
StandardModule: basMain
Sub CopyWkbVBA()
Dim sPath As String
sPath = Application.DefaultFilePath & "\temp.bas"
ActiveSheet.Copy
With ActiveSheet.Buttons(1)
.OnAction = ActiveWorkbook.Name & "!MeinMakro"
.Caption = "Meldung"
End With
Range("E8").Value = "Dieses Blatt wurde in eine neue Arbeitsmappe"
Range("E10").Value = "Arbeitsmappe übernommen wurde."
ThisWorkbook.VBProject.VBComponents("Modul1").Export sPath
ActiveWorkbook.VBProject.VBComponents.Import sPath
Kill sPath
End Sub