Public WithEvents Command2 As CommandButton 'SE CREA LOS EVENTOS DEL BOTON
Private Sub Command2_Click() 'NUEVO BOTON
MsgBox "Button Pressed"
End Sub
Private Sub Command1_Click()
'SE CARGA EN LA VARIABLE EN NUEVO BOTON
Set Command2 = Me.Controls.Add("VB.CommandButton", "Command2", Me)
'SE AGREGAN LAS PROPIEDADES
With Command2
.Visible = True
.Width = 900
.Height = 900
.Left = Me.Width / 2 - .Width / 2
.Top = Me.Height / 2 - .Height / 2
.Caption = "Test Button"
End With
End Sub