Results 1 to 2 of 2
  1. #1
    jkz
    Guest

    Setting Menu NAmes in VBA

    Anyone know how to do this? If you record adding a new menu you get the following lines of VBA:

    CommandBars("Menu Bar").Controls.Add _
    Type:=msoControlPopup, _
    Before:=3, Temporary:=True

    Actually I added the Temporary tag myself, but it is still a legal bit of code. What I can't record is setting the name of the menu, from "New Menu" to whatever...

    Also, the controlBars object doesn't seem to have a Name method. Arrghh!

    It must be here some where, can anyone point me in the right direction?

    tia

  2. #2
    Lounger
    Join Date
    May 2001
    Location
    the Netherlands
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting Menu NAmes in VBA

    Try using "Caption". An example:

    Dim menu As CommandBarControl
    Dim item As CommandBarButton

    Set menu = CommandBars("Standard").Controls.Add (Type:=msoControlPopUp, Before:=23)
    menu.Caption = "NameOfYourMenu"

    Set item = menu.Controls.Add(Type:=msoControlButton)
    With item
    .Caption = "Name"
    .Style = msoButtonCaption
    End With

    To get an accelerator put an ampersand in front of the character you want to use (e.g. "&Name").

    Ingrid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •