ADDMENU: Menu Addition (C2h)

The ADDMENU record stores a menu addition. When you add a menu object (a menu bar, a menu, a menu item, or a submenu item) to the user interface, Microsoft Excel writes a group of ADDMENU records for each object. The first record stores the menu bar, the second stores the menu, the third stores the menu item, and the fourth stores the submenu item (note how this is identical to the menu hierarchy in the user interface). The number of records in the group depends on the level of the menu structure at which the addition occurs. For example, adding a menu to a menu bar causes two ADDMENU records to be written. Adding a submenu item to a menu item causes four records to be written.

If fInsert is true (equal to 01h), the menu object is added at this level of the hierarchy. For example, if fInsert is true in the second ADDMENU record of the group, Microsoft Excel adds a new menu to an existing menu bar. If fInsert is false (equal to 00h), the record is a placeholder, and one of the following ADDMENU records in the group will define the menu addition.

For menu items and submenu items, the icetab field stores the index to the added command, if the item is attached to a built-in command. The icetabBefore field stores the index to the command before which the new command is added. If either of these indexes equals FFFFh, the corresponding string from the rgch field is used instead of a built-in command.

The caitm field is equal to the number of following ADDMENU records that are to be inserted at this level of the menu hierarchy.

Record Data

Offset

Name

Size

Contents

4

icetabItem

2

Icetab of the command

6

icetabBefore

2

Icetab of the existing command before which the new command is inserted

8

caitm

1

Number of ADDMENU records at the next level of the menu hierarchy

9

fInsert

1

= 1, insert this menu object
= 0, this is a placeholder record

10

rgch

var

stItem, stBefore, stMacro, stStatus, stHelp strings (see text)


The rgch field stores five concatenated strings, as described in the following table. Null strings will appear in the rgch field as a single byte (00h).

String

Contents

stItem

Text of the menu object

stBefore

Text of the item before which this item is added

stMacro

Macro name, encoded using a technique similar to the encoded file names in the EXTERNSHEET record (for more information, see "EXTERNSHEET" on page 310)

stStatus

Status bar text (for add-ins)

stHelp

Help file name and context ID (for add-ins)