Chào cả nhà! Em đang muốn tạo thêm 1 menu mới có tùy chọn. Câu hỏi cụ thể trong file đính kèm!
Private Sub BuiltPopup1()
Dim cBar As CommandBar
On Error Resume Next
Set cBar = CommandBars("ufPopup1")
If cBar Is Nothing Then
With CommandBars.Add("ufPopup1", 5)
With .Controls.Add(1)
.Caption = "Cong viec 1"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Cong viec 2"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Cong viec 3"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Thoat"
.OnAction = "dong"
End With
End With
End If
End Sub
Private Sub BuiltPopup2()
Dim cBar As CommandBar
On Error Resume Next
Set cBar = CommandBars("ufPopup2")
If cBar Is Nothing Then
With CommandBars.Add("ufPopup2", 5)
With .Controls.Add(1)
.Caption = "Cong viec 4"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Cong viec 5"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Cong viec 6"
'.OnAction = "thu tuc"
End With
With .Controls.Add(1)
.Caption = "Thoat"
.OnAction = "dong"
End With
End With
End If
End Sub
Private Sub Label1_Click()
CommandBars("ufPopup1").ShowPopup
End Sub
Private Sub Label2_Click()
CommandBars("ufPopup2").ShowPopup
End Sub
Private Sub UserForm_Initialize()
On Error Resume Next
BuiltPopup1
BuiltPopup2
End Sub
Private Sub UserForm_Terminate()
On Error Resume Next
CommandBars("ufPopup1").Delete
CommandBars("ufPopup2").Delete
End Sub
Vâng, thế là ổn rùi ah. Nhưng cho em hỏi thêm 1 câu hỏi nữa nhé: Giờ em muốn tạo menu con (menu cấp 2) thì phải viết code thế nào?