Working with Personalized Menus

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Personalized menus are a feature in Microsoft® Office XP that makes it possible for you see a collapsed subset of menu items that you use most often. You specify whether personalized menus are enabled by pointing to Toolbars on the View menu, clicking Customize, clicking the Options tab, and then selecting the Always show full menus commands first check box. Personalized menus are turned on by default.

Note   The personalized menus feature does not apply to shortcut menus.

You can turn on personalized menus for all command bars in an application or for individual command bars only. You can use the CommandBars collection's AdaptiveMenus property to specify whether personalized menus are on or off for all command bars. You use a CommandBar object's AdaptiveMenu property to specify whether that object's menus are displayed as personalized menus.

You use a CommandBarControl object's Priority property to specify whether a control on a menu will be visible when personalized menus are on. When you add a custom CommandBarControl object to a command bar, it will be visible by default. If you set a control's Priority property to 1, the control will always be visible. If you set the Priority property to 0, the control will initially be visible but might be hidden by the host application if it is not used regularly. When a control is hidden, it is still available on the menu, but you must expand the menu to see it.

The CommandBarControl object's IsPriorityDropped property specifies whether a control is currently displayed. When this property is set to True, the control is hidden. Selecting a control that has its IsPriorityDropped property set to True changes the property setting to False, which makes the control visible the next time its menu is displayed.

The host application might change the IsPriorityDropped property setting if the control is not used again within a certain time period. For more information about how long a control remains visible, search the Microsoft Office Visual Basic Reference Help index for "IsPriorityDropped property."

The following procedure turns personalized menus on or off for all command bars or a single command bar according to the value of the blnState argument:

Function SetPersonalizedMenuState(blnState As Boolean, _
                                Optional cbrBar As CommandBar = Nothing)
   ' This procedure sets the AdaptiveMenus property to the value of the
   ' blnState argument. If a CommandBar object is supplied in the cbrBar
   ' argument, the AdaptiveMenu property for that command bar is set to 
   ' the value of the blnState argument.
   On Error Resume Next
   If cbrBar Is Nothing Then
      Application.CommandBars.AdaptiveMenus = blnState
   Else
      cbrBar.AdaptiveMenu = blnState
   End If
End Function

The following procedure changes the setting of the Priority property for a menu item:

Function PromoteMenuItem(cbrBar As CommandBar, _
                         strItemCaption As String)
   ' This procedure changes the Priority property setting for the
   ' cbrBar command bar control whose Caption property setting
   ' matches the value of the strItemCaption argument.
   Dim ctlMenuItem As CommandBarControl

   On Error Resume Next
   If cbrBar.AdaptiveMenu = False Then Exit Function
   Set ctlMenuItem = cbrBar.Controls(strItemCaption)
   With ctlMenuItem
      If .Priority <> 1 Then
         .Priority = 1
      End If
   End With
End Function

See Also

Working with Command Bars | Manipulating Command Bars and Command Bar Controls with VBA Code | Getting Information About Command Bars and Controls | Creating a Command Bar | Hiding and Showing a Command Bar | Copying a Command Bar | Deleting a Command Bar | Preventing Users from Modifying Custom Command Bars | Working with Images on Command Bar Buttons | Working with Command Bar Controls | Working with Command Bar Events