Solved

How to find the parent menu item for a given menu item

Posted on 2003-11-25
7
185 Views
Last Modified: 2010-05-03
Hi,

Does anyone know how to get a reference to the parent menu item for a given menu item.
And also, how to get a list or collection of child menu items.

I've tried using the Parent property of a menu object but always refers to the parent form and not the parent menu item for a given sub item.

Any ideas ?

Alan.
0
Comment
Question by:aregan
  • 3
7 Comments
 
LVL 9

Expert Comment

by:p_sie
ID: 9817426
Don't think there is a parent property, but I did it as follows:

Name the parent menu-items mnuFile, mnuEdit
And name the child menu-items mnuFileOpen, mnuFileClose etc, mnuEditCut , etc.
This way you created your own stucture

You can make a list of the menu-items this way by

Dim ctl as Control
For each ctl in Form.Controls
    If Left(ctl.Name,3) = "mnu" THEN
           'Menu-item........
           'ctl.Name is the name used in code
           'ctl.Caption is the name by which the menu-item appears in the menu, remember to filter out the & in the Caption
    End If
Next
0
 
LVL 9

Expert Comment

by:p_sie
ID: 9940575
aregan,

is this question still open? I am just checking questions that I participated in and that were not closed yet!

Greetings, p_sie
0
 

Author Comment

by:aregan
ID: 9940789
Thanks P_Sie,

I was hoping that someone would come back with a suggestion on how to figure out the menu heirarchy at run time. BTW - I found using the following a little safer for getting a list of menus.

Dim ctl as Control
For each ctl in Form.Controls
    If TypeOf ctrl is Menu THEN
           'Menu-item........
           'ctl.Name is the name used in code
           'ctl.Caption is the name by which the menu-item appears in the menu, remember to filter out the & in the Caption
    End If
Next

Thanks,

Alan
0
 
LVL 9

Expert Comment

by:p_sie
ID: 9940796
That's maybe a better solution.
Good luck
0
 

Accepted Solution

by:
amp072397 earned 0 total points
ID: 10618832
PAQed, with points refunded (20)

Thanks very much!
amp, ee admin, amp*at*experts-exchange.com
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now