riktek
Member
- Local time
- Today, 04:46
- Joined
- Dec 15, 2023
- Messages
- 64
This is well and extensively discussed elsewhere but nevertheless all of the posted "solutions" fail and I am unable to programmatically minimize the ribbon but not the menu bar, as one can do by selecting the Menu Bar context menu's "Minimize the Ribbon" item (or pressing Ctrl + F1).
To be clear:
- Minimizing differs from hiding.
- At least two elements are involved, the Menu Bar and the Ribbon, which themselves are CommandBar objects and together may be elements of another CommandBar object, perhaps carrying a fourth element name, "Toolbar," which is undefined.
What I have observed is:
- By right clicking on the Menu Bar (but not the Ribbon), one can get a context / shortcut menu including a "Minimize the Ribbon" item, which, when selected, minimizes the ribbon but not the Menu Bar. This is the behavior I am attempting to replicate in code.
-
hides (not minimizes) both the Menu Bar and the Ribbon, and with no prospect of restoring the ribbon. I imagine this sets the Visible property of all CommandBar objects to False hides (not minimizes) both the Menu Bar and the Ribbon, and with no prospect of restoring the ribbon. I imagine this sets the Visible property of all CommandBar objects to False.
-
either fails or, if conditioned on some but not all values of CommandBar.Height, either fails or throws Error 5, "Invalid procedure call or argument"
ControlBars.Count is 199 but, quite oddly, attempts to iterate ControlBars.Item and ControlBar.Controls.Item with a For statement throw Error 9, "Subscript out of range" starting with both zero and 1.
Inspecting discrete ControlBar objects seems to reveal that neither has a "MinimizeRibbon" control.
and
both return an error. This would seem to explain the failure of
, at least when it isn't erroring, because it effectively just clicks the specified control.
Also, no obvious acCommand or acSysCmd constant exists for this action - many are undocumented, of course, but I haven't yet uncovered this one by Google or hack. I'm not aware of any means of getting this value from a menu or its items.
So, the question is whether, and how, one can programmatically minimize the ribbon and not the Menu Bar, as one can do by selecting the "Minimize the Ribbon" item in the Menu Bar's shortcut / context menu (or pressing Ctrl + F1). Many thanks for any constructive advice.
To be clear:
- Minimizing differs from hiding.
- At least two elements are involved, the Menu Bar and the Ribbon, which themselves are CommandBar objects and together may be elements of another CommandBar object, perhaps carrying a fourth element name, "Toolbar," which is undefined.
What I have observed is:
- By right clicking on the Menu Bar (but not the Ribbon), one can get a context / shortcut menu including a "Minimize the Ribbon" item, which, when selected, minimizes the ribbon but not the Menu Bar. This is the behavior I am attempting to replicate in code.
-
Code:
- DoCmd.ShowToolbar, "Ribbon", acToolBarNo
-
Code:
- CommandBars.ExecuteMso "MinimizeRibbon"
ControlBars.Count is 199 but, quite oddly, attempts to iterate ControlBars.Item and ControlBar.Controls.Item with a For statement throw Error 9, "Subscript out of range" starting with both zero and 1.
Inspecting discrete ControlBar objects seems to reveal that neither has a "MinimizeRibbon" control.
Code:
CommandBars.GetPressedMso("MinimizeRibbon")
Code:
CommandBars.GetVisibleMso("MinimizeRibbon")
Code:
CommandBars.ExecuteMso "MinimizeRibbon"
Also, no obvious acCommand or acSysCmd constant exists for this action - many are undocumented, of course, but I haven't yet uncovered this one by Google or hack. I'm not aware of any means of getting this value from a menu or its items.
So, the question is whether, and how, one can programmatically minimize the ribbon and not the Menu Bar, as one can do by selecting the "Minimize the Ribbon" item in the Menu Bar's shortcut / context menu (or pressing Ctrl + F1). Many thanks for any constructive advice.
Last edited: