Many of the Application object's methods and properties are also members of <globals>, which can be found at the top of the list of classes in the Object Browser, as shown in Figure 2-1.

If a property or method is in <globals>, you can refer to that property or method without a preceding reference to an object. For example, the following two references are equivalent:

Application.ActiveCell ActiveCell

However, you do need to be careful. It is easy to assume that frequently used Application object properties, such as ScreenUpdating, are <globals> when they are not. The following code is correct:

Application.ScreenUpdating = False

You will get unexpected results with the following:

ScreenUpdating = False

This code sets up a new variable and assigns the value False to it. You can easily avoid this error by having the line of code Option Explicit at the top of each module so that such references are flagged as undefined variables when your code is compiled.

Object Browser

Excel »f i iji f

1 1

■ A t

Classes o !<oiotiais> ; * SI Above Ave rage

M e m b ers of' <QI o ba l ÖP ActlveCell gE> ActlveCtiart

tïl Action

«E1 ActlvePrînter

SI Actions

Ef! ActiveSheet

¿S Addln

0 ActiveIWindo'A

ES Addlns

id1 Active JVorhboûK

S! Adjustments Si AlloWEdltRarge

ËÛ1 Addlns

Si AllortiEaitRangES

ËÛ1 Assistant

Si Application

<s Calculate

SJ Areas

irf Cells

SI AutoCorrect

li? Ctiarts

St Auto Fi lté r

Si ColorScaleBlachYvhlte

SI Auto Re cover

|JJ ColorScaleGYR

SI Aies

Œil ColorScaleRYG

SI Axis

® ColorScaleWhlteBlacK

Kl AïlsTitlF

iîS1 Columns


Property Abdication. As imnJicafirfl

Member of E'.tœr Gfotml

Remember that you can have Option Explicit automatically inserted in new modules if you use Tools O Options in the VBE window and, under the Editor tab, tick the Require Variable Declaration checkbox.

0 0

Post a comment