Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Tue, 5 Feb 2008 01:20:01 -0800,    group: microsoft.public.word.vba.addins        back       


Word Automation - Menu Separators   
I'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.

2 Questions:

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.)
date: Tue, 5 Feb 2008 01:20:01 -0800   author:   HaySeed

Re: Word Automation - Menu Separators   
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





"HaySeed"  wrote in message 
news:FFA81598-DEA5-4305-AEC0-9A6A4EC45771@microsoft.com...
> I'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.
>
> 2 Questions:
>
> 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.)
date: Wed, 6 Feb 2008 17:11:04 +1100   author:   Shauna Kelly

Re: Word Automation - Menu Separators   
Thanks Shauna

That was a valuable and unusually complete response.  I appreciate the extra 
effort.



"Shauna Kelly" wrote:

> 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
> 
> 
> 
> 
> 
> "HaySeed"  wrote in message 
> news:FFA81598-DEA5-4305-AEC0-9A6A4EC45771@microsoft.com...
> > I'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.
> >
> > 2 Questions:
> >
> > 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.) 
> 
> 
>
date: Wed, 6 Feb 2008 10:25:03 -0800   author:   HaySeed

Re: Word Automation - Menu Separators   
Read your responce to another. Good reply. My question is it possible to have 
msword 2000 macro reconize 1 comma as a seperator. When I record it shows  
Separator:=wdSeparateByCommas, In debug Commas=2 comma=0comma=1 not 
accepted. The text file I create in excel has 1 comma between fields. The 
macro in word will not go past the set delimiter screen no matter how I try 
to set it. Have been all over net with no avail. Appreciate any help Greatly
"Shauna Kelly" wrote:

> 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
> 
> 
> 
> 
> 
> "HaySeed"  wrote in message 
> news:FFA81598-DEA5-4305-AEC0-9A6A4EC45771@microsoft.com...
> > I'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.
> >
> > 2 Questions:
> >
> > 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.) 
> 
> 
>
date: Tue, 13 May 2008 22:52:03 -0700   author:   Curt

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us