This example creates a new toolbar called Demo. It has two buttons. The first one, labeled "Greetings" uses a VB command to display a message box. The second one, labeled "Say Hi" displays a similar message, but uses a macro to display the message. ShowAToolbar is used to display the new toolbar. SetToolbarPosition and SetToolbarMode are used to position the toolbar. The line continuation character (an underscore preceded by a space) is used to break up long lines.

Sub CreateDemoToolbar()

With Session

.NewToolbar "Demo"

.DefineToolbarButton "Demo", 1, False, "", 0, "", 0, _

"Greetings", "", "", rcVBCommand, "MsgBox ""Greetings"" "

.DefineToolbarButton "Demo", 2, False, "", 0, "", 0, _

"Say Hi", "", "", rcVBMacro, "Hi"

.ShowAToolbar "Demo", True

.SetToolbarMode "Demo", rcFloating

.SetToolbarPosition "Demo", 10, 10, 50, 200

End With

End Sub


'Here's the macro called by the second button

Sub Hi()

 MsgBox "Hi"

End Sub