Macro (SVB) Programs Example - Adding a Custom Toolbar via a SVB Macro Program

This example illustrates how to produce a custom toolbar and how to attach to it particular events. After running this program, a new toolbar will be added to your installation of Statistica.

' This program illustrates how to add a custom toolbar
' to your Statistica program. Use the Tools pulldown
' menu option Customize, and the Toolbar tab to remove
' the custom toolbar from your application, after you
' added it via this program (or write another program
' that will remove the toolbar via the CommandBar.Delete
' method).

' Retrieve the CommandBars object for the current
' application; note that CommandBars is a property
' of the Application object, so when running a VB
' program from another application, you need to explicitly
' declare the Statistica application object, and CommandBars
' as a property of that object.

Dim bars As CommandBars
bars = CommandBarOptions.CommandBars(scBarTypeToolbar)
newBar As CommandBar

' The new toolbar will be called "Custom"

Set newBar = bars.Add("Custom")

' Insert the following toolbar options in the toolbar

newBar.InsertButton 1, scCmdStatsBasicStatsTables , , _
"Basic Stats"

newBar.InsertButton 2, scCmdStatsNonparametrics , , _

' Insert a vertical separator line.

newBar.InsertSeparator 3

'Make this a floating toolbar.

newBar.Position = scBarFloating

'Set the display mode.

newBar.Item(1).DisplayMode = scCommandDisplayTextAndImage
newBar.Item(2).DisplayMode = scCommandDisplayTextAndImage

'Make a pop-up menu item on the new toolbar, labelled "Others"

Dim menu As CommandBarItem
menu = newBar.InsertPopupMenu(4, "Others")

'Insert the following menu option under the pop-up menu "Others"

menu.Items.InsertButton 1, scCmdStatsMultipleRegression , , _

menu.Items.InsertButton 2, scCmdStatsANOVA , , "ANOVA"
menu.Items.Item(1).DisplayMode= _

menu.Items.Item(2).DisplayMode= _

'Insert as a third option in "Others" a button that will run a
'macro program when selected. That macro program could, for example,

'run another application, or perform other customizations.

menu.Items.InsertMacroButton 3, _
& _
"\Examples\Macros\Graph Examples\Henon Strange Attractor.svb"
menu.Items.Item(3).Caption="My Macro"

End Sub

This program will create the following toolbar:


To remove the new toolbar, select Customize from the Tools menu to display the Customize dialog box. On the Toolbars tab, highlight the new toolbar and Delete it. (You could also write a SVB program to remove the new toolbar, using the CommandBar.Delete method.)