|
|
| Back to Excel Homepage | Excel VBA - Reference Guide |
|
Menu Object browser
Other links
|
The Object Browser enables you to see a list of all
the different objects with their methods, properties, events and
constants. In the VBE editor: 1. Insert menu and select a Module. 2. Click on the View menu and select Object Browser (shortcut key: F2). 3. Make sure it’s set to '<All Libraries>'.
Notice Add([Before], [After], [Count], [Type]) is one of the examples previously seen.
The main two panes contain on the left Classes (also known as Objects) and on the right Members (also known as Identifiers). By selecting a class, you display its members which are of three key types; Properties, Methods and Events. LibrariesLibraries are the application divisions of a collection of classes (objects). Therefore, you will have a class for Excel, VBA and other applications you wish to have a reference to. The Excel (the host), VBA and VBAProject are mandatory and can not disabled. All other library files can be switched on or off as required.
In order to code to another applications (for example, Microsoft Word) you will need to load its library first.
To switch between libraries or show all libraries, choose the ‘Project/Library’ drop down box:
The default libraries available:
Other libraries are also available but require to be enabled before they can be used which include Word, Outlook, DAO, ADODB and many others. By enabling the additional libraries, developers can start to code and communicate with other applications and processes, which start to reveal the potential power of Visual Basic (VBA). To enable a library, from the Visual Basic Editor, choose Tools menu and select References…
Scroll down to find the required library or choose the Browse… button to locate the required library. Excluding the top two libraries, a library priority order matters that is why users can re-arrange the order using the Priority buttons. The way the system works is when a procedure is executed, it checks to see which library is required in order to execute the line-by-line code. In some cases, a method or class can be duplicated between libraries and it is therefore important to be able to call the correct method or class first superseding the lower level references. Structure of a LibraryEach Library will typically have a collection of classes. A class or object class is in essence the object i.e. Worksheet. Each object class will have a collection of members, which could be a collection of properties, methods and events. When looking at the Object Browser, users will see on the left hand side many classes to the active library. To the right hand pane, all members of the selected class will reveal properties, methods and events.
The above illustration shows the Excel library, Worksheet class and the Visible property highlighted (Excel.Worksheet.Visible). Right mouse click the selected item to choose the Help command and go straight to the offline help documentation.
Browsing the right hand and pane of the Object Browser, users will see three different icons to help identify the member type:
Browser SearchingThe search tool allows users to locate if a keyword firstly exists and secondly where it could possibly reside At the top half of the browser window, type the desired keyword and then click the search button:
The above example looked for the keyword visible across all libraries. After locating the correct item (selecting the item), users can use the copy button function and then paste into a code window.
|
Tip: You can press F2 function key to load the Object Browser. |
|
© copyright 2010 TP Development & Consultancy Ltd, All Rights Reserved. All trademarks are copyrighted by their respective owners. Please read our terms of use and privacy policy. |