The Object Browser

The Object Browser provides the primary means to find objects and their associated properties and methods in Excel/VBA. It gives programmers a window to the object hierarchy in VBA and Excel, allowing them to inspect the objects available in VBA and Excel and their methods and properties. It can be accessed from the VBE either by clicking the Object Browser button on the Standard toolbar, or selecting Object Browser from the View menu.

'S Microsoft Visual Basic - Bookl (version l).xls - [Object Browser]

^ File Edit View Insert Format Debug Run Tools Add-Ins Window

project - veArt g

Click to select Object Browser m na

Properties - S

I Sheet WorksjJ Alphabetic iTEfP Sheetl DisplayPt False DisplayRr False EnableAi False EnableCeTrue EnableOi False EnablePh False EnableSeO - xlNc Name Sheet ScrollAre Standarc8.4: Wwihlp -1 / yIS

j All Libraries* 3^-JjJ f I

Classes of objects

Classes Q i<giobals> ^ Addln ^ Addlns

Adjustments 0 AllowEditRange AllowEditRanges AnswerWizard AnswerWizardFiles Application Areas Assistant Auto Correct 0 /uto Filter Auto Re cover Axes Axis AxisTitle 0 Balloon ^ BalloonCheckbox ^ BalloonCheckboxes lalloonLabel lalloonLabels

Members of "<globals>.

i* Abs Ép ACtive'Ceil 05* ActivaChart [sS? ActivePrinter ef ActiveSheet ï&(: ActiveWindow iif ActiveWorkbook ei? Atidlns

AppActivate d? Application

Asc .¡S Asc G m AscW lïS1 Assistant ■■a» Atn ■i» Beep «« Calcuiate (rfp Calendar y» CalIByName y» CBool m CByte CCur

Library list box

Members of the selected class

Libraries*

Figure 4.2 Selecting the Object Browser from the VBE

On entry to the Object Browser, you will see a screen similar to that in Figure 4.2. At the top left is a pull-down list of the Object model libraries, which includes the Excel and VBA library, as well as Office, VBA Project, and so on. The Excel library provides Help on all of the objects in the Excel object model, and their properties and methods. The VBA library provides Help on the VBA elements that are common to all applications that can use VBA, including Excel, Word, Access and PowerPoint. The default is All Libraries.

The left-hand pane lists all Classes of objects in the library, while the right-hand pane lists all the properties and methods associated with each selection. For example, Figure 4.4 shows a list of classes available with the Excel library. When a class is highlighted on the class list, then a complete list of properties and methods associated with it appears in the right-hand pane. Note that the Object Browser does not distinguish between properties and methods - they are listed together alphabetically. If an individual member of this list is highlighted (ChartArea, in Figure 4.3) then a description appears below this pane stating whether the selection is a property or method and a description of its use, such as:

Property ChartArea As ChartArea read-only

Member of Excel.Chart

¿gg Microsoft Visual Basic - Bookl (version 1).kIs - [Object Browser]

View Insert Format Debug Run Tools Add-Ins Window Help it ► II ■ tS" # ®

Properties - S

| Sheet WorksjJ Alphabetic

IBBM Sheetl DisplayPj False Dis play Ri False Enable Ai False EnableCeTrue | EnableOi False EnablePh False EnableSe 0 - xlNc Name Sheet 1 ScrollAre: Standarc8.43 Visible -1 - xlS

i MM

Classes 3l CellFormat Characters-

Chart

ChartArea 31 ChartColorFormat

■etiartFillForrrrat 31 ChartGroup

.ÇhartG roups 3} ChartObject SI ChartObjectS 3! Charts SI ChartTitle 31 Collection ^ CoiorConstants

CoiorFormat 31 COMAddln ' COMAddlns 31 CornmandBar

CommandBarButton 31 CommandBarComb CommansBarContrc 31 ComrnandBarContrc

Members of'Chart' f Activate i-s Activate Application ApptTCustomType ApplyDataLabels iM Area3DOroup

AreaGroups d? AutoScallng

Axe.S; l^1 BarSUQroup BarGroups"" BarShape F BeforeDoutileCIIck 9 BeforeRightCIIck f Calculate

« ChartGraups ChartObjects ChartTitle ri1 ChartType m ChartWIiard CheckSpelllng

Properties icon

Methods icon

FropertyClmilAiea As1 I11HA1 -

read-only

Member of &cel.Chart

Description of properties and methods associated with object member(s)

Figure 4.3 The Object Browser with an object and a property selected

Notice that properties are designated by the hand icon, whereas methods are indicated using a rectangular icon. The properties or methods of some objects may themselves be objects. For example, the ChartArea method of the Chart object in Figure 4.3 is itself an object and as such, the properties and methods of this object can be inspected (see Figure 4.4). One such method for this object is Copy.

<3 Microsoft Visual Basic - Bookl (version 1).hIs - [Object Browser]

^ File Edit View Insert Format Debug Run Tools Add-Ins Window Help

Properties - S

I Sheet Works_J Alphabetic

H5M Sheet! Display P< False DisplayRr False EnableAi False EnableCcTrue EnableOi False EnablePh False Enable5e0 - xlNc Name Sheet 1 ScrollAre Standarc8.43 Visible -1 - xl5

Classes ÜS CellFormat Characters-

■?■ i S ChartColorFormat S ChartFIIIFormat

ChartGroop 31 ChartGroups iS ChartObject SI ChartObjectS ¡¡3 Charts gS ChartTltle Collection Ä ColorConstants

ColorFormat gl COMAdoln COMAddlns S CornmandBar

ÇomrnandBarBotton 0 CommandBarComb GcrrirriarioBarCoritri S ComrnandBarContrc ^

Members of'ChartArea'

I^r1 Application l^1 AutoScaleFont Border Clear H C lea [Contents ^ ClearFormats

tf Creator Ef Fill l^? Font l^? Height l^1 interior rf Left l^? Name •f Parent Select f Shadow jig? Top Width

Copy method selected of object class: ChartArea

Fonction CopyO Member of Excel .ChaitAi •-■

Figure 4.4 Working deeper into the Object Browser

0 0

Post a comment