Hi
1. The CommandBarControl object and the CommandBarButton object both
have a .BeginGroup parameter. Set it to True to get Word to insert the
horizontal or vertical line before this item on a command bar or menu.
2. The top menu is just a command bar (named "Menu Bar"). So:
Sub xxx()
Dim barMenuBar As CommandBar
Dim oButton As CommandBarButton
Dim oMenu As CommandBarPopup
Dim oMenuButton As CommandBarButton
Application.CustomizationContext = ActiveDocument
Set barMenuBar = CommandBars("Menu Bar")
Set oButton = barMenuBar.Controls.Add(Type:=msoControlButton)
With oButton
.BeginGroup = True
.Caption = "Test button"
.Style = msoButtonCaption
End With
Set oMenu = barMenuBar.Controls.Add(Type:=msoControlPopup)
With oMenu
.BeginGroup = True
.Caption = "Test menu"
End With
Set oMenuButton = oMenu.Controls.Add(Type:=msoControlButton)
With oMenuButton
.Caption = "My button on a menu"
.Style = msoButtonCaption
End With
End Sub
3. Make sure you set the CustomizationContext before you begin. It's not
polite to change a user's Normal.dot. And, it's not good practice to set
the CustomizationContext to your addin or to a template and allow the
user to get a "do you want to save" message; so set the .Saved property
of the relevant template to True when you're finished.
Hope this helps.
Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
Post by HaySeedI'm using C# to automate a Word session. At the start of the session I build
a custom set of menu items under the "Tools" CommandBar.
1) How do I add a menu Separator into my custom menus
2) How do I add a new Item to the top menu Command Bar.
(When I try wordApp.CommandBars.Add() - I create an undocked Tool bar
instead of adding a menu item.)