Dyn. Code funktioniert nicht mit _Click-Prozedur
Brinkmann
folgendes Problem:
Ich lasse dynamisch eine Userform einschl. Commandbuttons erstellen:
Set Google = frmGeodatKor.Controls.Add("Forms.CommandButton.1")
With Google
.Name = "Google" & I
.Caption = "Prüfen"
End With
With ThisWorkbook.VBProject.VBComponents("frmGeodatKor").CodeModule
.InsertLines .CountOfLines + 1, "Public Sub " & Google.Name & "_Click()"
.InsertLines .CountOfLines + 1, "Msgbox(" & Chr(34) & "Hallo" & Chr(34) & ")" & vbLf
.InsertLines .CountOfLines + 1, "End Sub" & vbLf
End With
Erstellt wird die Userform dann korrekt, wie ich mir das vorstelle. Aber wenn ich auf die CommandButtons klicke, passiert nichts... Wieso?
In der Userform wird temporär folgender Code erzeugt:
Public Sub Google1_Click()
MsgBox ("Hallo")
End Sub
Public Sub Google2_Click()
MsgBox ("Hallo")
End Sub
Bin für jede Hilfe dankbar!
VG
Markus