How to set the position on the screen of the toolbars and menu bar
Article contributed by Dave Rado
You can use VBA to set the position of the toolbars and menu bar ( collectively known as CommandBars), using a number of methods.
1. |
You can set a CommandBar to be docked at the top, left, right, or bottom of the Word window, or to be floating, by using the Position method. For example: With
CommandBars("Formatting") Using the If statement as shown above prevents unnecessary flicker. |
2. |
You can set the docking order of a CommandBar relative to the other CommandBars in the same docking area by setting the RowIndex property. For example: With
CommandBars("Formatting") Warning: If your macro is to be run on other users' machines, you really need to set the RowIndex of all available CommandBars, or you are likely to get unpredictable results. |
3. |
You can set the distance (in pixels) from the left edge of the specified CommandBar to the left side of the docking area by using the Left property. The best plan is to first position your CommandBars manually where you want them to be, and get the appropriate measurements using code such as: MsgBox CommandBars("Formatting").Left Having found out what position you want to set a CommandBar to, you can then use code such as the following to set its position: With
CommandBars("Formatting") You would really need to test for the user's screen resolution first, as well as for whether they are using Large icons on their toolbar – setting different values as appropriate, for instance: Res = System.HorizontalResolution |