Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2002
    Location
    Duluth, Minnesota, USA
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Expanding or Nested Menu Selections (2K, SR-1)

    Is there a way to create expandable menu choices in Excel? I am looking for a way to create menu choices similar to what you see on the Excel menu bar when there are further choices to make for a menu item (there is a right-pointing triangle next to the expandable item).

    TIA, Douglas

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Expanding or Nested Menu Selections (2K, SR-1)

    Like this.

    <pre>Option Explicit

    Sub MakeMenu()
    Dim cControl1 As CommandBarControl
    Dim cControl2 As CommandBarControl
    RemoveMenu 'Prevent duplicate menu's
    Set cControl1 = Application.CommandBars(1).FindControl(ID:=30007). Controls.Add _
    (Type:=msoControlPopup, temporary:=True)
    cControl1.Caption = "&Test"
    Set cControl2 = cControl1.Controls.Add(Type:=msoControlButton, temporary:=True)
    With cControl2
    .Caption = "&SubMenu"
    .OnAction = "Test"
    End With
    Set cControl2 = cControl1.Controls.Add(Type:=msoControlButton, temporary:=True)
    With cControl2
    .Caption = "S&ubMenu1"
    .OnAction = "test1"
    End With
    On Error GoTo 0
    End Sub
    Sub RemoveMenu()
    On Error Resume Next
    Application.CommandBars(1).FindControl(ID:=30007). Controls("&Test").Delete
    On Error GoTo 0
    End Sub

    Sub test()
    MsgBox "Submenu entry 1 clicked"
    End Sub
    Sub test1()
    MsgBox "Submenu entry 2 clicked"
    End Sub

    </pre>

    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Expanding or Nested Menu Selections (2K, SR-1)

    Yes, but I don't have time to build you one (with luck someone may build one for you). Look at <!mskb=213550>Microsoft Knowledge Base Article 213550<!/mskb> and MS Office Commandbars, and the examples in PeltierTech and John Walkenbach for some starters.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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