coliervile
03-22-2008, 04:24 AM
Good morning to everyone...depending on where you are. I'm using "lucas" (thank you) floating toolbar on the KB (http://vbaexpress.com/kb/getarticle.php?kb_id=921). My question is...can you have more than one floating toolbar displayed simultaneously? My reason for asking is that I want different toolbars to perform different functions on the same worksheet. I'm making an interactive baseball scorecard and I want different toolbars for; how runners get on base; how batters make out; and ways runners advance, etc. I would also like to set the color for each toolbar to help the user to differentiate between the toolbars. This is an example of what I have for the toolbar for How Runners Get on Base; Any suggestions are also appreciated.
Sub AddNewToolBar()
' This procedure creates a new temporary toolbar.
Dim ComBar As CommandBar, ComBarContrl As CommandBarControl
On Error GoTo ErrorHandler
' Create a new floating toolbar and make it visible.
On Error Resume Next
'Delete the toolbar if it already exists
CommandBars("Baseball Scorecard Toolbar").Delete
Set ComBar = CommandBars.Add(Name:="How Runners Get on Base", Position:= _
msoBarFloating, Temporary:=True)
ComBar.Visible = True
' Create a button with text on the bar and set some properties.
Set ComBarC With ComBarContrl
.Caption = "Single"
. .TooltipText = "Run Single"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "Double"
. .TooltipText = "Run Double"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "Triple"
. .TooltipText = "Run Triple"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "HR"
. .TooltipText = "Run Home Run"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "BB"
. .TooltipText = "Run BB"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "HBP"
. .TooltipText = "Run HBP"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "FC"
. .TooltipText = "Run Fielders Choice"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "GRD"
. .TooltipText = "Run Ground Rule Double"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "WP"
. .TooltipText = "Run Wild Pitch"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "PB"
. .TooltipText = "Run Pass Ball"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "DI"
. .TooltipText = "Run Defenbive Interference"
'the onaction line tells the button to run a certain marcro
.
End With
Exit Sub
ErrorHandler:
MsgBox "Error " & Err.Number & vbCr & Err.Description
Exit Sub
End Sub
Sub AddNewToolBar()
' This procedure creates a new temporary toolbar.
Dim ComBar As CommandBar, ComBarContrl As CommandBarControl
On Error GoTo ErrorHandler
' Create a new floating toolbar and make it visible.
On Error Resume Next
'Delete the toolbar if it already exists
CommandBars("Baseball Scorecard Toolbar").Delete
Set ComBar = CommandBars.Add(Name:="How Runners Get on Base", Position:= _
msoBarFloating, Temporary:=True)
ComBar.Visible = True
' Create a button with text on the bar and set some properties.
Set ComBarC With ComBarContrl
.Caption = "Single"
. .TooltipText = "Run Single"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "Double"
. .TooltipText = "Run Double"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "Triple"
. .TooltipText = "Run Triple"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "HR"
. .TooltipText = "Run Home Run"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "BB"
. .TooltipText = "Run BB"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "HBP"
. .TooltipText = "Run HBP"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "FC"
. .TooltipText = "Run Fielders Choice"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "GRD"
. .TooltipText = "Run Ground Rule Double"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "WP"
. .TooltipText = "Run Wild Pitch"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "PB"
. .TooltipText = "Run Pass Ball"
'the onaction line tells the button to run a certain marcro
.
End With
Set ComBarC With ComBarContrl
.Caption = "DI"
. .TooltipText = "Run Defenbive Interference"
'the onaction line tells the button to run a certain marcro
.
End With
Exit Sub
ErrorHandler:
MsgBox "Error " & Err.Number & vbCr & Err.Description
Exit Sub
End Sub