Artashes Arabajyan
New Member
- Joined
- Jun 15, 2012
- Messages
- 1
Hi All,
I am trying get the click events of a label created on a frame, but unsuccessful. What am I doing wrong?
Here is the code:
I am trying get the click events of a label created on a frame, but unsuccessful. What am I doing wrong?
Here is the code:
Code:
Option Explicit
Private WithEvents lblCmdCancel As MSForms.Label
Private Sub CommandButton1_Click()
Dim frmMain As MSForms.Frame
Set frmMain = ActiveSheet.OLEObjects.Add(ClassType:="Forms.Frame.1").Object
With frmMain
.Caption = ""
.BorderStyle = fmBorderStyleSingle
.BorderColor = &H80000006
.Width = 164
.Height = 128
' Some code here ....
Set lblCmdCancel = .Controls.Add("Forms.Label.1", "lblCmdCancel", True)
With lblCmdCancel
.BackColor = &H80000000
.BorderStyle = fmBorderStyleSingle
.Left = 84
.Top = 102
.Width = 72
.Caption = "Cancel"
.TextAlign = fmTextAlignCenter
MsgBox .Name
End With
End With
End Sub
Private Sub lblCmdCancel_Click()
MsgBox "Clicked!"
End Sub