Page 391 - Microsoft Office Excel 2003 Programming Inside Out
P. 391

Part 5:  Manipulating Excel Objects


                     Chapter 17


                    Command Bars




                             Identifying Parts of the Menu System  .  365   Command Bar Controls . . . . . . . . . . . . . 371



                             The ability to manipulate menus in Microsoft Excel is very important when creating custom
                             add-ins. By trapping the appropriate events in an add-in, the add-in can automatically add
                             the appropriate menu items, making the add-in appear to be a standard part of Excel. In this
                             chapter, you’ll learn about the various objects associated with menus and toolbars and how to
                             add new menu items, modify existing menu items, and undo the changes your application
                             made, to restore Excel to its unmodified state.

                    Identifying Parts of the Menu System

                             Microsoft has developed a very flexible object model that combines menus, command but-
                             tons, combo boxes, and pop-up menus into a single extendable system. (See Figure 17-1.)
                             This system separates the visual presentation of the choices to the user from the underlying
                             hierarchical structure menus and buttons, which simplifies the development process.

                              Worksheet object

                                  PivotTables collection

                                       PivotTable object

                                           PivotCache object

                                           PivotFields collection
                                           (Also: ColumnFields,
                                           DataFields, HiddenFields,
                                           PageFields,  RowFields,
                                           VisibleFields, CalculatedFields
                                           collections)

                                               PivotField object

                                                    PivotItems collection

                                                        PivotItem object
                             Figure 17-1.  The CommandBar set of objects gives VBA programmers a lot of flexibility to
                             integrate their applications into Excel.

                                                                                                       365
   386   387   388   389   390   391   392   393   394   395   396