Hi, In my project I have a command bar which has 3 buttons. Enable Reminder, Time Reminder, Disable Reminder
I have the Enable Reminder and Disable reminder buttons working and am currently working on getting time reminder working, my problem is I want this button to disable itself after the user has pressed it - how would I go about doing this?
Currently this is the code I have for this command button.
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, temporary:=True) 'Adds a Menu Item to the Menu Bar
With cmbControl
.Caption = "LLE Encryption Reminder" 'Names the Menu Item
With .Controls.Add(Type:=msoControlButton) 'Adds a Dropdown Button to the Menu Item
.Caption = "Enable Reminder" 'Adds a Description to the Menu Item
.OnAction = "'EnableReminder'" 'Enable the Reminder
.FaceId = 343 'Assigns an Icon to the Dropdown
End With
With .Controls.Add(Type:=msoControlButton) 'Adds a Dropdown Button to the Menu Item
.Caption = "&Start Timer" 'Adds a Description to the Menu Item
.OnAction = "'StartTimer'" 'Time the Reminder
.FaceId = 126 'Assigns an Icon to the Dropdown
End With
With .Controls.Add(Type:=msoControlButton) 'Adds a Dropdown Button to the Menu Item
.Caption = "Disable Reminder" 'Adds a Description to the Menu Item
.OnAction = "'DisableReminder'" 'Disable the Reminder
.FaceId = 342 'Assigns an Icon to the Dropdown
End With
End With
TimerStart = False ' Set the timer start to false
Response = 7 ' Set the response to no by default
End Sub
Private Sub StartTimer()
If TimerStarted = False Then
TimerStarted = True
Response = 7
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=True
With cmbControl
With .Controls("&Start Timer")
.Controls("&Start Timer").Enabled = False
End With
End With
End If
End Sub
As you can see I have tried to disable this button - However I'm not to sure if this is the right approach?
Bookmarks