Article ID: 160293
Article Last Modified on 1/19/2007
CommandBars("Test").Controls("ClickMe")
CommandBars("Test").Controls(1)
Private Sub CommandBarTest_AfterUpdate()
Dim CBarMenu as CommandBar, CBarTool as CommandBar
Dim CBarCtl as CommandBarPopup
' Set the CommandBar objects to the menu bar and toolbar that
' display when you open a form in Form view.
Set CBarMenu = CommandBars("NorthwindCustomMenuBar")
Set CBarTool = CommandBars("Form View")
' Because the File menu is a Popup control, assign it to an object
' variable so you can manipulate its CommandBar object.
Set CBarCtl = CBarMenu.Controls("File")
' Program what happens when you click an option.
Select Case Me!CommandBarTest
' You clicked Dim View Menu.
Case 1
CBarMenu.Controls("View").Enabled = False
' You clicked Dim Print Button.
Case 2
CBarTool.Controls("Print...").Enabled = False
' You clicked Dim New Database.
Case 3
CBarCtl.CommandBar.Controls("New Database...").Enabled = _
False
' You clicked Enable All.
Case 4
CBarMenu.Controls("View").Enabled = True
CBarTool.Controls("Print...").Enabled = True
CBarCtl.CommandBar.Controls("New Database...").Enabled = _
True
End Select
End Sub
159692 ACC97: How to Create Command Bars Using Visual Basic Code
172300 ACC97: Command Bar Wizard Available in Download Center
Keywords: kbhowto kbprogramming kbusage KB160293