Listing all controls on all toolbars

The following procedure loops through all command bars in the collection. If the command bar is a toolbar —that is, if its Type property is set to msoBarTypeNormal — another loop displays the Caption for each toolbar button. msoBarTypeNormal is a built-in constant that has the value of 0.

Sub ShowAllToolbarControls() Dim row As Integer Dim Cbar As CommandBar Dim ctl As CommandBarControl

Cells.Clear row = 1

For Each Cbar In CommandBars

If Cbar.Type = msoBarTypeNormal Then Cells(row, 1) = Cbar.Name For Each ctl In Cbar.Controls Cells(row, 2) = ctl.Caption row = row + 1 Next ctl End If Next Cbar End Sub

Partial output of the ShowAllToolbarControls procedure is shown in Figure 22-9.

list all controls.xls

HE

A

B

C

79

Forms

¿Label

—i

80

¿Edit Box

81

¿Group Bom

82

C&heck Box

83

O&ption Button

84

L&ist Box

85

¿Combo Box

86

¿Combination List-Edit

87

¿Combination Drop-Down Edit

88

¿Scroll Bar

89

¿Spinner

90

Control Properties

91

¿Code

92

Toggle Grid

93

¿Run Dialoq

94

Stop Recording

Stop ¿Recording

95

Relative Reference

96

External Data

¿Edit Query...

97

D&ata Range Properties...

98

P ammeters...

99

¿Refresh Data

100

¿Cancel Refresh

101

Refresh ¿All

102

¿Refresh Status

103

Formula Auditing

Error Chec&king...

104

¿Trace Precedents

105

¿Remove Precedent Arrows

106

Trace ¿Dependents

107

¿Remove Dependent Arrows

-

► M \Sheetl /

HI

_J

► ir

Figure 22-9: A list of the captions for each control on all toolbars.

Figure 22-9: A list of the captions for each control on all toolbars.

0 0

Post a comment