Microsoft Office Tutorials and References
In Depth Information
Creating Toolbars
A toolbar is a collection of buttons arranged horizontally. You can mix and match various
types of buttons together in a single toolbar. (See Figure 17-4.)
Figure 17-4. You can combine multiple types of buttons into a single command bar to
create a toolbar.
The following routine was used to create the toolbar shown in Figure 17-4. The code begins
by locating the command bar that will hold the controls by using the CommandBars collec­
tion and specifying the desired name. Then the routine uses the Add method of the Controls
collection to create a new button. The button’s Style property is set the proper style for the
button, while the Caption property contains text that might or might not be displayed
depending on the type of button.
Sub CreateBar()
Dim c As CommandBar
Dim cb As CommandBarButton
Set c = Application.CommandBars("Excel2k3 VBA")
Set cb = c.Controls.Add(msoControlButton, 2)
cb.Style = msoButtonCaption
cb.Caption = "caption button with a long caption"
Set cb = c.Controls.Add(msoControlButton, 3)
cb.Style = msoButtonIcon
cb.Caption = "icon button"
Search JabSto ::




Custom Search