The Object Browser (F2)Probably the most overlooked and underused tool in the VBA programmer's arsenal is the Object Browser. This is unfortunate, because it is also one of the most important. The Object Browser is your window into the contents of the object libraries you're working with. For every object library marked under the VBE Tools > References menu, the Object Browser displays all of the objects, methods, properties, constants and enumerations supported by that object library.In addition to simply displaying these items, the Object Browser displays a brief description of the syntax required to use each item with hyperlinks to other items where applicable. For constants and enumerations, the Object Browser displays the actual numeric value of the constant or enumeration.The VBA help system is also directly linked to the object browser. If you need further explanation of some object, property or method you're looking at, you can just select the name of the item in the Object Browser and press F1 to bring up its help topic. (Specific constants and enumerations are rarely associated with help topics.)The Object Browser is packed with so many useful features that it could almost warrant a chapter in its own right. We cover the most commonly used features of the Object Browser in this section. An example of the Object Browser being used to display information about the ADO object library is shown in Figure 16-23. Figure 16-23. The VBE Object Browser![]() Basic FeaturesThe most commonly used features of the Object Browser window itself are the following:The Object Library Box This is the drop-down in the upper-left corner of the Object Library window. It determines which object library will be displayed in the Object Browser. The Object Library Box contains one entry for every referenced object library in the currently active project, one entry for the currently active project itself and a default <All Libraries> entry that causes the Object Browser to display all of the contents of all of the referenced libraries as well as the current project in one big heap. We recommend trying to narrow down the object library you want to examine by selecting it in this drop-down. Having everything displayed all at once makes any one thing difficult to locate.The Classes List This is the list that runs down the left side of the Object Browser window. Its name is a bit of a misnomer because it displays modules, constants and enumerations in addition to classes. This is the second level of detail you will look through after you've selected the object library you want to look in.The Members List This is the list that runs down the right side of the Object Browser window. It displays a complete list of members for whatever item is selected in the Classes List. For example, in Figure 16-23 the Command object has been selected in the Classes List, so the Members List displays all the members of the Command object.The Details Window This is the window that occupies the bottom of the Object Browser. It provides a description of the item that is currently selected in the Members List. For example, in Figure 16-23 the Execute method of the Command object has been selected in the Members List. The Details window provides a brief description of the syntax of this method with hyperlinks to related items in the object library. Advanced FeaturesThe Search Combo Box This is the combo box located directly below the Object Library drop-down. Using the Search combo box you can look for all occurrences of a given term within the object library or libraries currently selected in the Object Library Box. Just type the term you want to search for in the search combo box and click the Search button (the toolbar button that looks like a pair of binoculars). In Figure 16-24, for example, we've searched for all occurrences of the term ActiveConnection within the ADO object library. Figure 16-24. Using the Search Feature of the Object Browser![]() It may come as a surprise, but many elements of every object library are hidden from the default Object Browser view. There can be several reasons for this: the hidden features might not be usable from VBA, the hidden features might not be implemented at all, or the hidden features might be older features that Microsoft would like to discourage you from using. This last reason is why we can thank the Microsoft development team for providing us a way to make these hidden features visible. Some times these older features are useful, even necessary, for top- quality Excel development. Just don't expect to find any help topics linked to these hidden features. Figure 16-25 shows an excellent example of the value of the Show Hidden Members feature. Figure 16-25. Turning On Show Hidden Members![]() Notice that some of the items in the list are colored in very light gray. These are the hidden members that are revealed when you select the Show Hidden Members option. As discussed in Chapter 4 Worksheet Design, the controls from the Forms toolbar are often the best choice for use of controls on worksheets. Unfortunately, these controls date back prior to the Excel 97 era and even though they are fully supported by VBA it is not obvious how to find information on them unless you have a copy of Excel 5 or 95 running on a spare computer. As shown in ![]() |