The CommandBars.EnableDocking method is used to specify where a toolbar can be docked, and how it is displayed. The XTPToolBarFlags enumeration contains the different toolbar options that can be applied with the EnableDocking method. You can combine values to tailor to your needs, for example, you can specify that the toolbar can be docked only to the top or bottom of the application.
The picture below illustrates toolbars docked to several different locations in the application.
The code below illustrates how to limit a toolbar so that is can only be docked to the top and bottom of the application, or it can be a floating toolbar.
Dim ToolBar As CommandBar Set ToolBar = CommandBars.Add("Standard", xtpBarTop) ToolBar.EnableDocking xtpFlagAlignBottom Or xtpFlagAlignTop _ Or xtpFlagFloating
The completely disable docking, simply pass in a 0 or a flag such as xtpFlagStretched into the EnableDocking method for a toolbar.
Dim ToolBar As CommandBar Set ToolBar = CommandBars.Add("Standard", xtpBarTop) ToolBar.EnableDocking 0