Most objects in Excel have several members in common as listed in Table 4-5.
Table 4-5. Common Excel object members
Member |
Description |
Use to |
---|---|---|
Returns the Excel |
This isn’t really useful from within Excel since the | |
Returns a numeric code identifying the application that created the object |
Again, this isn’t really useful from within Excel. You can pretty much ignore this property. | |
|
Returns the next-higher object in Excel’s object hierarchy |
Map Excel’s object hierarchy. |
Name |
Returns a string describing the object |
Display information about an object or get a specific object from a collection. |
You might be able to tell from Table 4-5 that the Name
property is the most useful of the common members
. Most (but not all) Excel objects have a Name
property that identifies the object within its containing collection. For example, Worksheets("Sheet1")
returns the worksheet with the Name
property Sheet1
.
That’s not true for all objects, however. The Range
object, for instance, has an Address
property instead of a Name
property. Other objects, such as Window
, use the Caption
property, instead. Table 4-6 categorizes some of the common members that aren’t as universal as those listed in Table 4-5, but are actually more useful to know.
Table 4-6. Other useful, common members by category
Category |
Member |
Use to |
---|---|---|
General |
|
Set focus on an object. |
|
Set or return the text that appears in an object’s titlebar. | |
|
Set or return the value displayed by an object. This is often the default property of an object. | |
Collections |
|
Create a new object and add it to the collection. |
|
Get the number of objects in a collection. | |
|
Get the position of an object within a collection (use on the object, not the collection). | |
|
Get an object by name or index from a collection. This is the default property of most collections. | |
|
Remove an object from a collection (use on the object, not the collection). | |
Appearance |
|
Set or return the height of an object in points. (There are 72 points in an inch.) |
|
Set or return the horizontal position of an object in points. | |
|
Set or return the vertical position of an object in points. | |
|
Show or hide an object (True/False). | |
|
Set or return the width of an object in points. | |
Printing |
|
Print an object. |
|
View the object before printing. |
The following sections explain using these common members.
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.