Get References

As the top-level object in Excel, Application is the source of all other object references. However, the object name Application isn’t always used in code because Excel includes shortcuts (called global members ) that let you omit it. For instance, the following two lines are equivalent:

Application.Selection.Clear ' Clear selected cells.
Selection.Clear             ' Same thing!
Use Application properties to get or set these options

Figure 7-2. Use Application properties to get or set these options

In this case, Selection returns the selected cells on the active worksheet as a Range object. Table 7-2 lists the Application members that return references to other objects.

Table 7-2. Application object members that return object references

ActiveCell

ActiveChart

ActivePrinter

ActiveSheet

ActiveWindow

ActiveWorkbook

AddIns

Assistant

AutoCorrect

AutoRecover

Cells

Charts

Columns

COMAddIns

CommandBars

Dialogs

ErrorCheckingOptions

FileDialog

FileFind

FileSearch

FindFile

FindFormat

International

Intersect

LanguageSettings

Names

NewWorkbook

ODBCErrors

OLEDBErrors

PreviousSelections

Range

RecentFiles

Rows

RTD

Selection

Sheets

SmartTagRecognizers

Speech

SpellingOptions

ThisCell

ThisWorkbook

Union

UsedObjects

Watches

Windows

Workbooks

WorksheetFunction

Worksheets

Most of the names of the members in Table 7-2 are descriptive of the objects they return. The exceptions to that rule are the members that ...

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.