In Outlook 2010 I have a userform called UserForm1.
Here I create a button dynamically and show the form.
How can I add an event (the sub btnLoad_OnClick
) when the button was clicked?
Here is my code:
Dim btnLoad As MSForms.CommandButton
Sub btnLoad_OnClick()
MsgBox ("Button Clicked")
End Sub
Sub SaveAttachment()
Set btnLoad = UserForm1.Controls.Add("Forms.CommandButton.1", "btnLoad", True)
With btnLoad
.Caption = "Click Me"
.Left = 30
.Top = 30
.Height = 30
.Width = 60
End With
With UserForm1
.Width = 850
.Show
End With
End Sub