Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA open file from excel cell 4 44
Updates not working for MS Windows 7 12 181
Determine Range to Select 5 52
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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