Listing all Command Bar objects

If you're curious about the objects in the CommandBars collection, enter and execute the following macro. The result is a list of all CommandBar objects in the CommandBars collection, plus any custom menu bars or toolbars. For each CommandBar, the procedure lists its Index, Name, and Type. (The Type can be 0, 1, or 2).

Sub ShowCommandBarNames() Dim Row As Long Dim cbar As CommandBar Row = 1

For Each cbar In Application.CommandBars Cells(Row, 1) = cbar.Index Cells(Row, 2) = cbar.Name Cells(Row, 3) = cbar.Type Row = Row + 1 Next cbar End Sub

Figure 19-8 shows a portion of the result of running this procedure, which is available at this book's Web site. As you can see, Excel has a lot of CommandBars.

Figure 19-8:

A VBA macro produced this list of all Com-mandBar objects.

a

show commândbàr names.xls

u.

oil

g

B

c

S

E

1

1

y^Grifeheet Menu Bat

1

2

2

Chart Menu Bar

1

3-

'3

Standard

0

gffl

4

Form ailing

i

S

'5

PiyotTable

0

6-

S

CJiart

.0

7

7

Revre^inq

0.

8

fl

Forms

0

3

'3

igfop Recrafiiin'q-

:n

j?'

10

External Data

0

11

11

Formula-Auditing

0

12

12

Fullscreen

0

13

13

Circular Reference

0

14

14

Visual Basic;

B

IS

SS

Web

0

IS

ÏS

Control Toolbox

0

17

17.

Gjiil Desiqritvlode

:D

13

13

Refresh

0

10

19

Watch Window

0

20

PitfdfTaMs Field List

§

8H

21

B{Jtiiirs

0

;22

22

Protection

0

>

-

y -

► K . Rheetl J

l<!

iii.

0 0

Post a comment