Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Custom Menu Hierarchies

Latest post Tue, May 27 2008 2:22 PM by MrPogle. 2 replies.
  • Tue, May 27 2008 1:11 PM

    • MrPogle
    • Top 50 Contributor
    • Joined on Tue, May 27 2008
    • Posts 5
    • Points 57

    Custom Menu Hierarchies

    I have created a multi-level custom shortcut menu in Excel 2003. I can use:

    Application.CommandBars.ActionControl.Caption

    to find out what selection has been chosen but I also want to know what selections were made further back up the hierarchy that got to the selection in the first place.

    • Post Points: 21
  • Tue, May 27 2008 1:36 PM In reply to

    Re: Custom Menu Hierarchies

    This seems to walk its way back up the tree nicely, even if you append part way down an exsiting menu

     

    Dim ctl As CommandBarControl
    Dim ctlparent As CommandBarControl
    Dim msg As String

        Set ctl = Application.CommandBars.ActionControl
        msg = ctl.Caption
        Do
            Set ctlparent = Nothing
            On Error Resume Next
            Set ctlparent = ctl.Parent.Parent
            On Error GoTo 0
            If Not ctlparent Is Nothing Then
           
                Set ctl = ctlparent
                msg = msg & vbNewLine & ctl.Caption
            End If
        Loop Until ctlparent Is Nothing
        MsgBox msg

    Regards

    Bob

    • Post Points: 21
  • Tue, May 27 2008 2:22 PM In reply to

    • MrPogle
    • Top 50 Contributor
    • Joined on Tue, May 27 2008
    • Posts 5
    • Points 57

    Re: Custom Menu Hierarchies

    Thanks very much - worked a treat!

     

    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.