官术网_书友最值得收藏!

Using the Object Browser in the VBA Editor

This recipe covers usage of the Object Browser in the VBA Editor. The name says it all; the Object Browser lets you browse through the objects available to you.

In later recipes, we will look into the autocompletion of our code. For instance, when you type the name of an object in the code window and type a dot, a context menu appears with a list of actions you can choose from:

Figure 3.9 – The context menu with available library options

The green icons are methods, including cutting, pasting, and clearing contents. The other icons are properties. You can, in other words, choose methods or properties here, or use the Object Browser, as described hereafter.

Getting ready

Make sure that a blank workbook is active in Excel.

How to do it…

  1. Activate the VBA Editor by pressing Alt + F11.
  2. With the Editor active, press F2 to activate the Object Browser. You can also do this by clicking on View | Object Browser:

    Figure 3.10 – The Object Browser

  3. The drop-down list in the top left-hand corner, just under the title bar, contains a list of all the object libraries that are currently available. Figure 3.10 displays the Excel libraries.
  4. Just below that, a second drop-down list lets you enter a search string. In this example, I searched for all Excel objects that deal with open.
  5. The object library now displays everything that contains the text open. If you want to know more about Close, for instance, click on that object and press F1 for more information.
  6. There is also the Auto List Members feature. It provides a list of properties and methods as you type. Figure 3.11 shows an example of this for the worksheets collection:

Figure 3.11 – The Auto List Members option

How it works…

The Object Browser is a tool in the VBA Editor that lets you browse through the objects available to you.

The Auto List Members feature provides a list of properties and methods as you type. It eliminates some typing, and also ensures that the property or method is spelled correctly.

主站蜘蛛池模板: 凤山县| 乌鲁木齐市| 通河县| 大连市| 泸水县| 周宁县| 光山县| 资源县| 资源县| 郓城县| 浮梁县| 怀仁县| 久治县| 洛浦县| 板桥市| 石泉县| 宁德市| 榆树市| 宁河县| 蒲城县| 沐川县| 兰考县| 长春市| 蒙山县| 阿拉尔市| 工布江达县| 青神县| 崇文区| 虞城县| 迁安市| 塔城市| 塔河县| 从江县| 襄汾县| 美姑县| 龙江县| 铜梁县| 石家庄市| 汕尾市| 建昌县| 兴和县|