Microsoft Office Tutorials and References
In Depth Information
Introducing the Visual Basic Editor
Continuing with the analogy, a fast-food restaurant (like a workbook) contains objects, such as
the Kitchen , DiningArea , and Tables (a collection). Furthermore, management can add or
remove objects from the Restaurant object. For example, management can add more tables
to the Tables collection. Each of these objects can contain other objects. For example, the
Kitchen object has a Stove object, a VentilationFan object, a Chef object, a Sink
object, and so on.
So far, so good. This analogy seems to work. Let’s see whether I can take it further.
Excel objects have properties. For example, a Range object has properties such as Value and
Name , and a Shape object has properties such as Width and Height . Not surprisingly, objects
in a fast-food restaurant also have properties. The Stove object, for example, has properties
such as Temperature and NumberofBurners . The VentilationFan object has its own set
of properties ( TurnedOn , RPM , and so on).
Besides properties, Excel’s objects also have methods, which perform operations on objects. For
example, the ClearContents method erases the contents of a Range object. An object in a
fast-food restaurant also has methods. You can easily envision a ChangeThermostat method
for a Stove object, or a SwitchOn method for a VentilationFan object.
With Excel, methods sometimes change an object’s properties. The ClearContents method
for a Range object changes the Range Value property. Similarly, the ChangeThermostat
method on a Stove object affects its Temperature property.
With VBA, you can write procedures to manipulate Excel’s objects. In a fast-food restaurant, the
management can give orders to manipulate the objects in the restaurants. (“Turn on the stove
and switch the ventilation fan to high.”) Now is it clear?
Introducing the Visual Basic Editor
All your VBA work is done in the Visual Basic Editor (VBE). The VBE is a separate application that
works seamlessly with Excel. By seamlessly, I mean that Excel takes care of the details of opening
the VBE when you need it. You can’t run VBE separately; Excel must be running in order for the
VBE to run.
VBA modules are stored in workbook files. However, the VBA modules aren’t visible
unless you activate the VBE.
Search JabSto ::

Custom Search