Need Menu to Toggle On & Off

  • Thread starter Thread starter BobV
  • Start date Start date
B

BobV

Group:

I need some help in creating a menu item that when selected the first time
will toggle on and put a checkmark next to the menu item. And when selected
a second time by the user will toggle off and remove the checkmark.

How do I make such a menu item. Do I accomplish this by VBA code? If so, can
you give me a sample of the VBA code?

Any help will be greatly appreciated.

Thanks,
BobV
 
Bob

This may help.

Regards
Geoff


Sub ControlOnAction()
' Assumes:
' There's a CommandBar called "BobV".
' The first control on the CommandBar
' is a drop-down menu.
' The first control on the drop-down
' menu needs to be checked/unchecked.
' This subprocedure is called by the OnAction
' property of first control on the
' drop-down menu.

Static blnState As Boolean

If blnState Then
' Code when checked control is clicked.
MsgBox "I unchecked the control."
Else
' Code when unchecked control is clicked.
MsgBox "I checked the control."
End If

' Reverse the state property
' (TRUE = Checked, FALSE = Unchecked):
CommandBars("BobV").Controls(1).Controls(1).State = Not blnState

blnState = Not blnState

End Sub
 
Back
Top