Datasheet
Using the Visual Basic Editor
586
At the risk of confusing matters, typing the following line in the Immediate
window returns the same result:
? CurrentProject.AllForms.Count
The shortened version works because the Application option is the
default parent object used if you don’t specify a parent object before
CurrentProject. (The Application object is the parent of Current-
Project
because CurrentProject is a member of the Application
object library.)
The bottom line is that when you see a bunch of words separated by dots in
code (such as
CurrentProject.AllForms.Count), be aware that those
words refer to some object. In a sense, the words are a path to the object —
going from the largest object down to a single, specific object, property,
method, or event. You can use the Object Browser as a means of looking up
the meanings of the words to gain an understanding of how the pre-written
code works.
As you gain experience, you can use the Object Browser to look up informa-
tion about objects, collections, properties, methods, events, and constants
within your code. For now, consider the Object Browser as a tool for discov-
ering VBA as you go.
Choosing object libraries
Most likely, the object libraries that appear automatically in the Object
Browser’s Project/Library drop-down list are all you need. However, should a
given project require you to add some other object library, follow these
steps to add it:
1. Choose Tools➪References from the Visual Basic Editor main menu.
The References dialog box opens.
2. Choose any library name from the list.
In the unlikely event that you need a library that isn’t in the list — but
you know you stored it on your hard drive — click the Browse button,
navigate to the folder that contains the object library you need, click its
name, and then click the Open button.
3. Click OK when the object libraries you need have check marks.
The Project/Library list in the Object Browser now includes all the
libraries you selected in the References dialog box.
38_036494 bk08ch01.qxp 11/17/06 8:34 AM Page 586