Solved

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

Posted on 2003-11-25
7
187 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

809 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