runtime Control and code in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i want to add runtime command button and want to add click event to this button.

Pls help me out .

Thanx in advance.

Anu
 
Anu,

This goes into a userform:

Public WithEvents cmdButton As MSForms.CommandButton

Sub testit()
Set cmdButton = Me.Controls.Add("Forms.CommandButton.1", "cmdMyButton")
cmdButton.Caption = "Click Me"
End Sub

Private Sub cmdButton_Click()
MsgBox "Hello"
End Sub


Rob
 
Back
Top