Menus Property (AMenu)

Returns a reference to a collection of menus contained on the menu object.

Syntax

 [ pMenu = ] Object.Menus ( vKey )

The Menus property syntax has the following parts:

 

Name

Type

Description

Object

AMenu

AMenu object

vKey

Val Variant

A value that identifies a member of a menus collection contained on the menu object.

pMenu

AMenu

The menu returned on the AMenu object.

Comments

This property is read-only at run time.

The Menus property is similar to the Menus property on the Form object, and is accessed in a similar manner. For example, use the following code to get the Top property of the second submenu on the menu object:

amnu12top = mnu1.Menus(2).Top

Since a menu is an object and can contain submenus, which are also objects, each submenu has its own set of properties, methods, and events. For example: the following statement returns the value of the Grayed property of the third submenu of the second submenu on the AMenu:

amnu1 = mnu1.Menus(2).Menus(3).Grayed

With the Menus property, you can iterate through all the menus on a menu object and change the properties of each menu as in the following code:

! Previously declare mnuX As Menu

For mnuX In mnu1.Menus

mnuX.Type = amenuTypeItem

Next

Example

The following statement returns the first submenu on the AMenu:

amnu1 = mnu1.Menus(1)

The following statement returns the third submenu of the second submenu on the AMenu:

amnu1 = mnu1.Menus(2).Menus(3)

The following statement returns the submenu named "View" on the AMenu:

amnu1 = mnu1.Menus("View")

Applies to

AMenu

See Also

MenusCount