Hi,
I'm using the following code to create a menu.
What I would like is for the Get Settings item only to be active when comms has been started and greyed out the rest of the time.
Similarly when comms has been started I want it to be greyed out and when stopped for stop comms to be greyed out.
I'm using the following code to create a menu.
Code:
Sub Add_Workbook_Menu_And_Items()
Dim newMenu, newMenuItem
On Error GoTo oops
'delete the menu if it exists by calling this subroutine
Remove_Workbook_Menu
With CommandBars("Worksheet Menu Bar")
Set newMenu = .Controls.Add(Type:=msoControlPopup, before:=.Controls("Window").Index, temporary:=True)
End With
'give the new menu a name
newMenu.Caption = "&Controls"
'add a menu item to the new menu
Set newMenuItem = newMenu.Controls.Add(Type:=msoControlButton)
'give the new menu a name and assign a macro to it
newMenuItem.Caption = "&Start Comms"
newMenuItem.OnAction = "comstart"
Set newMenuItem = newMenu.Controls.Add(Type:=msoControlButton)
'give the new menu a name and assign a macro to it
newMenuItem.Caption = "&Stop Comms"
newMenuItem.OnAction = "comstop"
Set newMenuItem = newMenu.Controls.Add(Type:=msoControlButton)
'give the new menu a name and assign a macro to it
newMenuItem.Caption = "&Get Settings"
newMenuItem.OnAction = "settings"
Exit Sub
oops:
MsgBox "An error has occured, cannot create the menu items. " & Chr(13) & Chr(13) & _
"Error number: " & Err.Number & Chr(13) & "Error Description: " & Err.Description, vbCritical + vbOKOnly, "Ooops..."
Application.ScreenUpdating = True
End Sub
What I would like is for the Get Settings item only to be active when comms has been started and greyed out the rest of the time.
Similarly when comms has been started I want it to be greyed out and when stopped for stop comms to be greyed out.