Members that Return Children

Many of the members of the Application object are designed simply to gain access to a child object of the Application object. For instance, the Workbooks property simply returns the Workbooks collection object, which represents all of the currently open Workbook objects (i.e., workbooks). We will discuss many of these objects at the proper time, but it is worth taking a look at the members that return these objects now.

Table 16-2 shows the 48 members of the Application object that return child objects.

Table 16-2. Members that return child objects

Name

ReturnType

ActiveCell

Range

ActiveChart

Chart

ActiveDialog

Dialog Sheet

ActiveMenuBar

MenuBar

Active Window

Window

Active Workbook

Workbook

Addlns

AddIns

Application

Application

AutoCorrect

AutoCorrect

AutoRecover

AutoRecover

Cells

Range

Charts

Sheets

Columns

Range

DefaultWebOptions

DefaultWebOptions

Dialogs

Dialogs

DialogSheets

Sheets

ErrorCheckingOptions

ErrorCheckingOptions

Excel4IntlMacro Sheets

Sheets

Excel4Macro Sheets

Sheets

FindFormat

CellFormat

Intersect

Range

MenuBars

MenuBars

Modules

Modules

Names

Names

NextLetter

Workbook

ODBCErrors

ODBCErrors

OLEDBErrors

OLEDBErrors

Parent

Application

Range

Range

RecentFiles

RecentFiles

ReplaceFormat

CellFormat

Rows

Range

RTD

RTD

Sheets

Sheets

ShortcutMenus

Menu

SmartTagRecognizers

SmartTagRecognizers

Speech

Speech

SpellingOptions

SpellingOptions

ThisCell

Range

ThisWorkbook

Workbook

Toolbars

Toolbars

Union

Range

UsedObjects

UsedObjects

Watches

Watches

Windows

Windows

Workbooks

Workbooks

WorksheetFunction

WorksheetFunction

Worksheets

Sheets

There are some points worth noting in Table 16-2. First, there are several members that begin with the word "Active." It should come as no surprise that these members return the corresponding currently active object. For instance, the ActiveSheet member returns the currently active worksheet or chart, depending upon which is active at the time. (Note that there is no Sheet object. Sheets are either worksheets or stand-alone charts. We will discuss this issue in detail in Chapter 18.)

Observe also that often the name of a member is the same as the name of the object that the member returns. For instance, the AddIns property returns the AddIns collection, the Application property returns the Application object, and the Windows property returns the Windows collection.

The notable exceptions to this rule are:

• The ThisWorkBook property returns the Workbook object containing the currently running code. One use of this property is in determining the location (complete path and filename) of the workbook on the user's computer, which is done by writing:

ThisWorkbook.FullName

• Several object properties, such as Cells, Columns, and Rows, return a Range object. This is because there are no Cell, Column, or Row objects in the Excel object model. Instead, each of these "objects" is actually a Range object. (Incidentally, a similar thing happens in the Word object model. In particular, there are no Character, Word, or Sentence objects. Rather, these are Range objects in the Word object model as well.)

0 0

Post a comment